C++ アルゴリズムとデータ構造のライブラリ
#include "library/graph/route_restore.hpp"$O(L)$
auto [dis, route] = dijkstra(G, {s});
vector<int> pth = route_restore(route, goal);
#pragma once
vector<int> route_restore(const vector<int> &route, int goal) {
vector<int> path = {goal};
while (!!~route[path.back()]) path.push_back(route[path.back()]);
reverse(path.begin(), path.end());
return path;
}#line 2 "library/graph/route_restore.hpp"
vector<int> route_restore(const vector<int> &route, int goal) {
vector<int> path = {goal};
while (!!~route[path.back()]) path.push_back(route[path.back()]);
reverse(path.begin(), path.end());
return path;
}