結果
問題 | No.1382 Travel in Mitaru city |
ユーザー |
|
提出日時 | 2021-02-07 21:54:41 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 399 ms / 2,000 ms |
コード長 | 580 bytes |
コンパイル時間 | 344 ms |
コンパイル使用メモリ | 82,176 KB |
実行使用メモリ | 98,616 KB |
最終ジャッジ日時 | 2024-07-04 15:20:20 |
合計ジャッジ時間 | 15,058 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 68 |
ソースコード
import sysimport heapqinput = sys.stdin.buffer.readlineN, M, S, T = map(int, input().split())S -= 1T -= 1P = tuple(map(int, input().split()))G = [[] for _ in range(N)]for _ in range(M):a, b = (int(x) - 1 for x in input().split())G[a].append(b)G[b].append(a)h = [(-P[S], S)]nonvisited = [True] * Nnonvisited[S] = Falseans = 0X = P[S]while h:p, v = heapq.heappop(h)if -p < X:X = -pans += 1for x in G[v]:if nonvisited[x]:heapq.heappush(h, (-P[x], x))nonvisited[x] = Falseprint(ans)