結果
| 問題 | No.1382 Travel in Mitaru city |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-11-08 10:19:32 |
| 言語 | PyPy3 (8.0.1 + ACL) |
| 結果 |
MLE
不安定
|
| 実行時間 | - |
| コード長 | 839 bytes |
| 記録 | |
| コンパイル時間 | 83 ms |
| コンパイル使用メモリ | 64,128 KB |
| 実行使用メモリ | 656,268 KB |
| 最終ジャッジ日時 | 2026-11-08 10:19:43 |
| 合計ジャッジ時間 | 7,641 ms |
|
ジャッジサーバーID (参考情報) |
judge7_0 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 3 MLE * 1 -- * 64 |
ソースコード
import heapq
N,M,s,t = map(int,input().split())
P = [0]+list(map(int,input().split()))
G = {i:[] for i in range(1,N+1)}
for _ in range(M):
a,b = map(int,input().split())
G[a].append(b)
G[b].append(a)
T = [[i,0] for i in range(N+1)]
def tfind(x):
while T[x][0]!=x:
x=T[x][0]
return T[x][0]
def tunion(x,y):
rx = tfind(x)
ry = tfind(y)
if rx==ry:
return
if T[rx][1]>T[ry][1]:
T[ry][0] = rx
elif T[rx][1]<T[ry][1]:
T[rx][0] = ry
else:
T[ry][0] = rx
T[rx][1] += 1
que = []
X = P[s]
Y = 0
for x in G[s]:
heapq.heappush(que,(-P[x],x))
while que:
p,x = heapq.heappop(que)
p = -p
if p<X:
Y += 1
X = p
tunion(s,x)
for y in G[x]:
if tfind(y)!=tfind(s):
heapq.heappush(que,(-P[y],y))
print(Y)