結果

問題 No.2805 Go to School
ユーザー YuuuTYuuuT
提出日時 2024-07-12 22:14:17
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,692 ms / 2,000 ms
コード長 1,181 bytes
コンパイル時間 251 ms
コンパイル使用メモリ 82,224 KB
実行使用メモリ 177,948 KB
最終ジャッジ日時 2024-07-16 01:40:26
合計ジャッジ時間 16,269 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 44 ms
54,272 KB
testcase_01 AC 42 ms
54,400 KB
testcase_02 AC 42 ms
54,144 KB
testcase_03 AC 41 ms
54,272 KB
testcase_04 AC 261 ms
122,368 KB
testcase_05 AC 626 ms
112,812 KB
testcase_06 AC 256 ms
92,672 KB
testcase_07 AC 363 ms
95,768 KB
testcase_08 AC 472 ms
114,908 KB
testcase_09 AC 338 ms
95,232 KB
testcase_10 AC 179 ms
91,648 KB
testcase_11 AC 459 ms
145,536 KB
testcase_12 AC 282 ms
105,472 KB
testcase_13 AC 407 ms
112,896 KB
testcase_14 AC 112 ms
89,344 KB
testcase_15 AC 41 ms
54,400 KB
testcase_16 AC 41 ms
54,400 KB
testcase_17 AC 39 ms
54,272 KB
testcase_18 AC 388 ms
103,020 KB
testcase_19 AC 294 ms
96,644 KB
testcase_20 AC 863 ms
120,960 KB
testcase_21 AC 768 ms
153,088 KB
testcase_22 AC 305 ms
111,720 KB
testcase_23 AC 450 ms
115,712 KB
testcase_24 AC 693 ms
115,072 KB
testcase_25 AC 421 ms
108,060 KB
testcase_26 AC 684 ms
166,596 KB
testcase_27 AC 413 ms
150,272 KB
testcase_28 AC 82 ms
83,712 KB
testcase_29 AC 89 ms
84,352 KB
testcase_30 AC 181 ms
118,144 KB
testcase_31 AC 529 ms
108,288 KB
testcase_32 AC 1,292 ms
177,948 KB
testcase_33 AC 1,692 ms
160,548 KB
testcase_34 AC 48 ms
62,080 KB
testcase_35 AC 46 ms
61,568 KB
testcase_36 AC 391 ms
103,268 KB
testcase_37 AC 389 ms
109,056 KB
testcase_38 AC 312 ms
128,000 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# 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)
  
0