結果
問題 |
No.2805 Go to School
|
ユーザー |
|
提出日時 | 2025-03-08 09:09:56 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 914 bytes |
コンパイル時間 | 379 ms |
コンパイル使用メモリ | 82,716 KB |
実行使用メモリ | 126,636 KB |
最終ジャッジ日時 | 2025-04-09 15:44:10 |
合計ジャッジ時間 | 17,756 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 35 WA * 1 |
ソースコード
import heapq N,M,L,S,E = map(int,input().split()) G = {i:[] for i in range(1,N+1)} for _ in range(M): a,b,t = map(int,input().split()) G[a].append((b,t)) G[b].append((a,t)) T = list(map(int,input().split())) INFTY = 10**15 dist1 = [INFTY for _ in range(N+1)] dist1[1] = 0 que = [(0,1)] while que: d,x = heapq.heappop(que) if dist1[x]<d:continue for y,t in G[x]: if dist1[y]>d+t: dist1[y] = d+t heapq.heappush(que,(d+t,y)) T1 = [] for a in T: if dist1[a]<=S+E: T1.append(a) dist2 = [INFTY for _ in range(N+1)] dist2[N] = 0 que = [(0,N)] while que: d,x = heapq.heappop(que) if dist2[x]<d:continue for y,t in G[x]: if dist2[y]>d+t: dist2[y] = d+t heapq.heappush(que,(d+t,y)) ans = INFTY for a in T1: d = max(dist1[a],S)+1+dist2[a] ans = min(ans,d) if ans>=INFTY: print(-1) else: print(ans)