結果
問題 |
No.2805 Go to School
|
ユーザー |
|
提出日時 | 2024-07-03 22:31:28 |
言語 | PyPy3 (7.3.15) |
結果 |
RE
|
実行時間 | - |
コード長 | 794 bytes |
コンパイル時間 | 294 ms |
コンパイル使用メモリ | 81,920 KB |
実行使用メモリ | 133,128 KB |
最終ジャッジ日時 | 2024-07-04 21:13:54 |
合計ジャッジ時間 | 11,866 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | RE * 4 |
other | RE * 34 |
ソースコード
from heapq import* N,M,L,S,E=map(int,input().split()) gr=[[] for i in range(N*2)] edge=[] for i in range(M): a,b,t=map(int,input().split()) gr[(a-1)*2].append(((b-1)*2,t)) gr[(b-1)*2].append(((a-1)*2,t)) gr[(a-1)*2+1].append(((b-1)*2+1,t)) gr[(b-1)*2+1].append(((a-1)*2+1,t)) L=int(input()) T=list(map(int,input().split())) for t in T: gr[(t-1)*2].append(((t-1)*2+1,-1)) dist=[1<<60]*N*2 dist[0]=0 vert=[(0,0)] while vert: dis,pos=heappop(vert) if dist[pos]!=dis: continue for t,c in gr[pos]: nxt=dis+c if c==-1: if dis>=S+E: continue nxt=max(S,dis)+1 if dist[t]>nxt: dist[t]=nxt heappush(vert,(nxt,t)) if dist[-1]>=1<<60: print(-1) else: print(dist[-1])