結果
| 問題 |
No.2805 Go to School
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-07-13 00:36:20 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 846 bytes |
| コンパイル時間 | 417 ms |
| コンパイル使用メモリ | 82,304 KB |
| 実行使用メモリ | 264,740 KB |
| 最終ジャッジ日時 | 2024-07-13 00:36:27 |
| 合計ジャッジ時間 | 5,245 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | TLE * 1 -- * 33 |
ソースコード
from collections import defaultdict,deque
N,M,L,S,E=map(int,input().split())
G=[[] for _ in range(N+1)]
D=defaultdict(int)
for _ in range(M):
a,b,t=map(int,input().split())
if a>b:a,b=b,a
G[a].append(b)
G[b].append(a)
if D[(a,b)]==0:D[(a,b)]=t
else:D[(a,b)]=min(D[(a,b)],t)
T=set(map(int,input().split()))
vis=[(1<<60,0) for _ in range(N+1)]
Q=deque()
# 現在地、時間、トイレ済
Q.append((1,0,0))
while Q:
p,t,u=Q.popleft()
vis[p]=(t,u)
for n in G[p]:
if p<n:a,b=p,n
else:a,b=n,p
nt=t
if S+E<nt+D[(a,b)] and b in T:
nt+=1;u=1
if nt+D[(a,b)]<vis[n][0]:
Q.append((n,nt+D[(a,b)],u))
if vis[N][0]==1<<60:
print(-1)
else:
ans=vis[N][0]
if vis[N][0]<S:
ans=S+1
elif vis[N][1]==0:
ans=vis[N][0]+1
print(ans)