library

This documentation is automatically generated by online-judge-tools/verification-helper

View the Project on GitHub rainbou-kpr/library

:heavy_check_mark: test/yosupo-shortest-path.test.py

Depends on

Code

# verification-helper: PROBLEM https://judge.yosupo.jp/problem/shortest_path
from py.graph import Graph


def main():
    n, m, s, t = map(int, input().split())
    g = Graph(n)
    g.read(m, 0, True, True)
    dist, prev = g.shortest_path(s, True)
    if dist[t] == -1:
        exit(print(-1))
    route = []
    cur = t
    while cur != s:
        route.append((prev[cur].src, prev[cur].dst))
        cur = prev[cur].src
    print(dist[t], len(route))
    for src, dst in route[::-1]:
        print(src, dst)


if __name__ == "__main__":
    main()
Traceback (most recent call last):
  File "/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/onlinejudge_verify/documentation/build.py", line 71, in _render_source_code_stat
    bundled_code = language.bundle(stat.path, basedir=basedir, options={'include_paths': [basedir]}).decode()
  File "/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/onlinejudge_verify/languages/python.py", line 93, in bundle
    raise NotImplementedError
NotImplementedError
Back to top page