結果
問題 |
No.2805 Go to School
|
ユーザー |
![]() |
提出日時 | 2024-07-14 04:59:15 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 967 bytes |
コンパイル時間 | 332 ms |
コンパイル使用メモリ | 82,672 KB |
実行使用メモリ | 122,144 KB |
最終ジャッジ日時 | 2025-04-09 15:42:24 |
合計ジャッジ時間 | 13,987 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 35 WA * 1 |
ソースコード
import sys input = sys.stdin.readline from heapq import heappop,heappush N,M,L,S,E=map(int,input().split()) EDGE=[[] for i in range(N+1)] for i in range(M): a,b,t=map(int,input().split()) EDGE[a].append((b,t)) EDGE[b].append((a,t)) T=set(map(int,input().split())) DIS=[1<<60]*(N+1) DIS[1]=0 Q=[(0,1)] while Q: dis,fr=heappop(Q) if DIS[fr]!=dis: continue for to,cost in EDGE[fr]: if DIS[to]>dis+cost: DIS[to]=dis+cost heappush(Q,(DIS[to],to)) DIS2=[1<<60]*(N+1) DIS2[N]=0 Q=[(0,N)] while Q: dis,fr=heappop(Q) if DIS2[fr]!=dis: continue for to,cost in EDGE[fr]: if DIS2[to]>dis+cost: DIS2[to]=dis+cost heappush(Q,(DIS2[to],to)) ANS=1<<60 for i in range(1,N+1): if (i in T) and DIS[i]<=S+E: t=max(DIS[i],S) ANS=min(ANS,t+DIS2[i]+1) if ANS<=(1<<50): print(ANS) else: print(-1)