結果
| 問題 | No.2805 Go to School |
| コンテスト | |
| ユーザー |
るこーそー
|
| 提出日時 | 2024-09-28 00:05:44 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
AC
|
| 実行時間 | 707 ms / 2,000 ms |
| コード長 | 797 bytes |
| 記録 | |
| コンパイル時間 | 242 ms |
| コンパイル使用メモリ | 96,104 KB |
| 実行使用メモリ | 162,632 KB |
| 最終ジャッジ日時 | 2026-07-08 14:30:27 |
| 合計ジャッジ時間 | 14,853 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 36 |
ソースコード
import sys
input=sys.stdin.readline
from heapq import heappush,heappop
n,m,l,s,e=map(int,input().split())
graph=[[] for _ in range(2*n)]
for _ in range(m):
a,b,c=map(int,input().split())
a,b=a-1,b-1
graph[2*a].append((c,2*b))
graph[2*b].append((c,2*a))
graph[2*a+1].append((c,2*b+1))
graph[2*b+1].append((c,2*a+1))
for t in map(int,input().split()):
t-=1
graph[2*t].append((-1,2*t+1))
dist=[float('INF')]*2*n
dist[0]=0
que=[(0,0)]#(dist,vertex)
while que:
d,v=heappop(que)
if d>dist[v]:continue
for nc,nv in graph[v]:
nd=d+nc
if nc==-1:
if d>=s+e:continue
nd=max(s,d)+1
if dist[nv]>nd:
dist[nv]=nd
heappush(que,(nd,nv))
print(dist[-1] if dist[-1]!=float('INF') else -1)
るこーそー