結果
問題 | No.2805 Go to School |
ユーザー |
![]() |
提出日時 | 2024-07-14 04:59:15 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 881 ms / 2,000 ms |
コード長 | 967 bytes |
コンパイル時間 | 294 ms |
コンパイル使用メモリ | 82,232 KB |
実行使用メモリ | 122,640 KB |
最終ジャッジ日時 | 2024-07-16 01:43:08 |
合計ジャッジ時間 | 14,518 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 35 |
ソースコード
import sysinput = sys.stdin.readlinefrom heapq import heappop,heappushN,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]=0Q=[(0,1)]while Q:dis,fr=heappop(Q)if DIS[fr]!=dis:continuefor to,cost in EDGE[fr]:if DIS[to]>dis+cost:DIS[to]=dis+costheappush(Q,(DIS[to],to))DIS2=[1<<60]*(N+1)DIS2[N]=0Q=[(0,N)]while Q:dis,fr=heappop(Q)if DIS2[fr]!=dis:continuefor to,cost in EDGE[fr]:if DIS2[to]>dis+cost:DIS2[to]=dis+costheappush(Q,(DIS2[to],to))ANS=1<<60for 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)