|
|
@ -61,8 +61,8 @@ map<Day12::Vertex, uint64> Day12::dijkstra(Graph &graph, Vertex start) { |
|
|
|
|
|
|
|
|
|
|
|
queue.erase(u); |
|
|
|
queue.erase(u); |
|
|
|
|
|
|
|
|
|
|
|
for (const Vertex &v : queue){ |
|
|
|
for (const Vertex &v : graph.out[u]){ |
|
|
|
if (!graph.E.contains({u, v})) |
|
|
|
if (!queue.contains(v)) |
|
|
|
continue; |
|
|
|
continue; |
|
|
|
|
|
|
|
|
|
|
|
size_t newDist = dist[u] + 1; |
|
|
|
size_t newDist = dist[u] + 1; |
|
|
@ -100,10 +100,14 @@ Day12::Graph Day12::parseGraph(bool reverse) { |
|
|
|
auto checkEdges = [&g, readChar, this](Vertex v1, Vertex v2){ |
|
|
|
auto checkEdges = [&g, readChar, this](Vertex v1, Vertex v2){ |
|
|
|
char c1 = readChar(input[v1.second][v1.first]); |
|
|
|
char c1 = readChar(input[v1.second][v1.first]); |
|
|
|
char c2 = readChar(input[v2.second][v2.first]); |
|
|
|
char c2 = readChar(input[v2.second][v2.first]); |
|
|
|
if (c2 <= c1 + 1) |
|
|
|
if (c2 <= c1 + 1){ |
|
|
|
g.E.insert({v1, v2}); |
|
|
|
g.E.insert({v1, v2}); |
|
|
|
if (c1 <= c2 + 1) |
|
|
|
g.out[v1].insert(v2); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (c1 <= c2 + 1) { |
|
|
|
g.E.insert({v2, v1}); |
|
|
|
g.E.insert({v2, v1}); |
|
|
|
|
|
|
|
g.out[v2].insert(v1); |
|
|
|
|
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
for (Vertex v : g.V){ |
|
|
|
for (Vertex v : g.V){ |
|
|
|