結果
| 問題 | No.1382 Travel in Mitaru city |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-11-18 21:08:26 |
| 言語 | PyPy3 (8.0.1 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 346 ms / 2,000 ms |
| + 748µs | |
| コード長 | 653 bytes |
| 記録 | |
| コンパイル時間 | 88 ms |
| コンパイル使用メモリ | 64,388 KB |
| 実行使用メモリ | 92,776 KB |
| 最終ジャッジ日時 | 2026-11-18 21:08:58 |
| 合計ジャッジ時間 | 20,419 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 68 |
ソースコード
from heapq import heappush, heappop
N, M, S, T = map(int, input().split())
S -= 1
T -= 1
P = list(map(int, input().split()))
G = [list() for _ in range(N)]
for i in range(M):
u, v = map(int, input().split())
u -= 1
v -= 1
G[u].append(v)
G[v].append(u)
visited = [False]*N
que = []
heappush(que, (-P[S], S)) # 人口、pos
min_p = 10**18
ans = -1
while que:
p, pos = heappop(que)
p *= -1
if p < min_p:
ans += 1
min_p = p
if visited[pos]:
continue
visited[pos] = True
for nex in G[pos]:
if visited[nex]:
continue
heappush(que, (-P[nex], nex))
print(ans)