結果
問題 | No.1382 Travel in Mitaru city |
ユーザー |
![]() |
提出日時 | 2023-04-13 12:47:28 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 447 ms / 2,000 ms |
コード長 | 622 bytes |
コンパイル時間 | 193 ms |
コンパイル使用メモリ | 82,048 KB |
実行使用メモリ | 96,104 KB |
最終ジャッジ日時 | 2024-10-09 11:02:14 |
合計ジャッジ時間 | 18,461 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 68 |
ソースコード
import sysreadline = sys.stdin.readlinefrom heapq import *N, M, S, T = map(int, readline().split())S, T = S - 1, T - 1P = list(map(int, readline().split()))G = [[] for i in range(N)]for i in range(M):A, B = map(int, readline().split())A, B = A - 1, B - 1G[A].append(B)G[B].append(A)Q = []Q.append((-P[S], S))ans = -1now = 10 ** 18seen = [0] * Nwhile Q:c, u = heappop(Q)c = -cif seen[u]:continueseen[u] = 1if c < now:ans += 1now = cfor v in G[u]:if seen[v]:continueheappush(Q, (-P[v], v))print(ans)