結果
問題 | No.2366 登校 |
ユーザー | flygon |
提出日時 | 2023-06-30 23:10:35 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,475 bytes |
コンパイル時間 | 879 ms |
コンパイル使用メモリ | 87,000 KB |
実行使用メモリ | 79,284 KB |
最終ジャッジ日時 | 2023-09-22 05:21:03 |
合計ジャッジ時間 | 9,919 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 170 ms
78,784 KB |
testcase_01 | AC | 104 ms
77,272 KB |
testcase_02 | AC | 134 ms
78,044 KB |
testcase_03 | WA | - |
testcase_04 | AC | 103 ms
77,216 KB |
testcase_05 | AC | 122 ms
77,676 KB |
testcase_06 | AC | 163 ms
78,420 KB |
testcase_07 | AC | 181 ms
79,068 KB |
testcase_08 | AC | 195 ms
78,544 KB |
testcase_09 | AC | 187 ms
79,268 KB |
testcase_10 | AC | 139 ms
78,236 KB |
testcase_11 | AC | 127 ms
78,392 KB |
testcase_12 | TLE | - |
testcase_13 | -- | - |
testcase_14 | -- | - |
testcase_15 | -- | - |
testcase_16 | -- | - |
testcase_17 | -- | - |
testcase_18 | -- | - |
testcase_19 | -- | - |
testcase_20 | -- | - |
testcase_21 | -- | - |
testcase_22 | -- | - |
testcase_23 | -- | - |
testcase_24 | -- | - |
testcase_25 | -- | - |
testcase_26 | -- | - |
ソースコード
import sys sys.setrecursionlimit(5*10**5) input = sys.stdin.readline from collections import defaultdict, deque, Counter from heapq import heappop, heappush from bisect import bisect_left, bisect_right from math import gcd n,m,k,t = map(int,input().split()) t = min(t, 500) wonderc = defaultdict() wonderd = defaultdict() for i in range(k): a,b,c,d = map(int,input().split()) wonderc[(a,b)] = c wonderd[(a,b)] = d #ダイクストラ法 def dijkstra(s): # sがスタート、nが頂点数 INF = 10**15 dist = [[INF]*(1000) for i in range(n*m)] que = [(0,s,500)] dist[s][500] = 0 while que: c,crr,tt = heappop(que) x,y = crr//m, crr%m # print(x,y,tt) if c > dist[crr][tt]: continue if (x,y) in wonderc.keys(): if dist[crr][max(0, tt-wonderc[(x,y)]+1)] > dist[crr][tt]+wonderd[(x,y)]: dist[crr][max(0, tt-wonderc[(x,y)]+1)] = dist[crr][tt]+wonderd[(x,y)] heappush(que,(dist[crr][max(0, tt-wonderc[(x,y)]+1)],crr, max(0, tt-wonderc[(x,y)]+1))) for dx,dy in [[0,1],[0,-1],[1,0],[-1,0]]: nx,ny = x+dx,y+dy if not(0<=nx<n and 0<= ny<m): continue nxt = nx*m + ny if dist[crr][tt] < dist[nxt][min(1000-1,tt+1)]: dist[nxt][min(1000-1,tt+1)] = dist[crr][tt] heappush(que,(dist[nxt][min(1000-1,tt+1)],nxt,min(1000-1,tt+1))) return dist d =dijkstra(0) print(min(d[-1][:t+500]))