結果
| 問題 | No.1382 Travel in Mitaru city |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-02-08 11:50:51 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 763 bytes |
| 記録 | |
| コンパイル時間 | 434 ms |
| コンパイル使用メモリ | 82,304 KB |
| 実行使用メモリ | 740,024 KB |
| 最終ジャッジ日時 | 2024-07-05 08:08:55 |
| 合計ジャッジ時間 | 6,238 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 2 WA * 6 MLE * 1 -- * 59 |
ソースコード
from collections import deque
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 = deque([(S,P[S],0)])
X,Y = 0,0
while st:
i,x,y = st.popleft()
if i == T:
X,Y = x,y
break
for j in l[i]:
if P[j] < x:
x = P[j]
y += 1
st.append((j,x,y))
st = deque([(T,X,Y)])
visited = [False]*N
while st:
i,x,y = st.popleft()
Y = max(Y,y)
for j in l[i]:
if not visited[j]:
visited[j] = True
if P[j] < x:
x = P[j]
y += 1
st.append((j,x,y))
print(Y)