test/cpv/library-checker-graph/shortest_path.cpp
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | // competitive-verifier: PROBLEM https://judge.yosupo.jp/problem/shortest_path | ||
| 2 | #include "../../../src/graph/ds/alist/lib.hpp" | ||
| 3 | #include "../../../src/graph/sp/dijkstra/lib.hpp" | ||
| 4 | #include "../../../src/io/fastin/lib.hpp" | ||
| 5 | #include "../../../src/io/fastout/lib.hpp" | ||
| 6 | |||
| 7 | using namespace tifa_libs; | ||
| 8 | 29 | int main() { | |
| 9 | u32 n, m, s, t; | ||
| 10 | 29 | fin_uint >> n >> m >> s >> t; | |
| 11 | 29 | alist<u64> g(n); | |
| 12 |
2/2✓ Branch 0 taken 10191615 times.
✓ Branch 1 taken 29 times.
|
10191644 | for (u32 i = 0, a, b, c; i < m; ++i) { |
| 13 | 10191615 | fin_uint >> a >> b >> c; | |
| 14 | 10191615 | g.add_arc(a, b, c); | |
| 15 | } | ||
| 16 |
1/2✓ Branch 1 taken 29 times.
✗ Branch 2 not taken.
|
29 | veci pre(n, -1); |
| 17 | 4631835 | auto dis = dijkstra(g, s, [&pre](u32 now, u32 to) { pre[to] = (i32)now; }); | |
| 18 | 29 | veci ans; | |
| 19 |
3/4✓ Branch 2 taken 1445665 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 1445665 times.
✓ Branch 6 taken 29 times.
|
1445694 | for (i32 now = pre[t]; ~now; now = pre[(usz)now]) ans.push_back(now); |
| 20 |
2/2✓ Branch 1 taken 4 times.
✓ Branch 2 taken 25 times.
|
29 | if (ans.empty()) { |
| 21 | 4 | fout << "-1\n"; | |
| 22 | 4 | return 0; | |
| 23 | } | ||
| 24 | 25 | fout << dis[t] << ' ' << ans.size() << '\n'; | |
| 25 |
2/2✓ Branch 7 taken 1445640 times.
✓ Branch 8 taken 25 times.
|
1445665 | for (u32 i = u32(ans.size() - 1); i; --i) fout << ans[i] << ' ' << ans[i - 1] << '\n'; |
| 26 | 25 | fout << ans[0] << ' ' << t << '\n'; | |
| 27 | 25 | return 0; | |
| 28 | 29 | } | |
| 29 |