結果
| 問題 |
No.2805 Go to School
|
| コンテスト | |
| ユーザー |
YuuuT
|
| 提出日時 | 2024-07-12 22:14:17 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 1,181 bytes |
| コンパイル時間 | 276 ms |
| コンパイル使用メモリ | 82,292 KB |
| 実行使用メモリ | 177,656 KB |
| 最終ジャッジ日時 | 2025-04-09 15:39:42 |
| 合計ジャッジ時間 | 17,232 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 35 WA * 1 |
ソースコード
# oj t -c "python3 main.py"
import sys,math
from collections import defaultdict,deque
from itertools import combinations,permutations,accumulate,product
from bisect import bisect_left,bisect_right
from heapq import heappop,heappush,heapify
#from sortedcontainers import SortedList,SortedSet
def input():return sys.stdin.readline().rstrip()
def ii(): return int(input())
def ms(): return map(int, input().split())
def li(): return list(map(int,input().split()))
inf = pow(10,18)
mod = 998244353
#//////////////////////////////////
N,M,L,S,E = ms()
G = [set() for _ in range(N+1)]
for _ in range(M):
u,v,c = ms()
if u==v: continue
G[u].add((v,c))
G[v].add((u,c))
T = set(li())
H = []
heappush(H,(0,1,0))
dist = [[inf,inf] for _ in range(N+1)]
while H:
c,v,f = heappop(H)
if v==N and f==1:
print(c)
exit()
if dist[v][f]<c: continue
dist[v][f] = c
for v2,c2 in G[v]:
if f==0 and v2 in T and c+c2<=S+E:
if dist[v2][1]<=max(c+c2,S)+1: continue
dist[v2][1] = max(c+c2,S)+1
heappush(H,(max(c+c2,S)+1,v2,1))
if f==0 and c+c2>S+E: continue
if dist[v2][f]<=c+c2: continue
dist[v2][f] = c+c2
heappush(H,(c+c2,v2,f))
print(-1)
YuuuT