結果
| 問題 |
No.1382 Travel in Mitaru city
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-02-08 12:47:49 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 511 ms / 2,000 ms |
| コード長 | 549 bytes |
| コンパイル時間 | 221 ms |
| コンパイル使用メモリ | 81,664 KB |
| 実行使用メモリ | 98,248 KB |
| 最終ジャッジ日時 | 2024-07-05 09:10:19 |
| 合計ジャッジ時間 | 21,754 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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()))
l = [[] for _ in range(N)]
for _ in range(M):
a,b = map(int,input().split())
a -= 1
b -= 1
l[a].append(b)
l[b].append(a)
st = [(-P[S],S)]
visited = [False]*N
visited[S] = True
ans = 0
x = P[S]
while st:
pi,i = heappop(st)
pi = -pi
if x > pi:
x = pi
ans += 1
for j in l[i]:
if not visited[j]:
visited[j] = True
heappush(st,(-P[j],j))
print(ans)