結果
問題 | No.1382 Travel in Mitaru city |
ユーザー |
![]() |
提出日時 | 2021-02-11 15:46:45 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 341 ms / 2,000 ms |
コード長 | 555 bytes |
コンパイル時間 | 169 ms |
コンパイル使用メモリ | 82,960 KB |
実行使用メモリ | 98,444 KB |
最終ジャッジ日時 | 2024-07-18 04:28:01 |
合計ジャッジ時間 | 15,962 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 68 |
ソースコード
from heapq import heappop, heappush n, m, s, t = map(int, input().split()) s -= 1 t -= 1 p = list(map(int, input().split())) to = [[] for _ in range(n)] for _ in range(m): a, b = map(int, input().split()) a -= 1 b -= 1 to[a].append(b) to[b].append(a) added = [False] * n added[s] = True q = [(-p[s], s)] x, y = p[s], 0 while q: pi, i = heappop(q) pi = -pi if pi < x: x = pi y += 1 for v in to[i]: if added[v]: continue added[v] = True heappush(q, (-p[v], v)) print(y)