結果
問題 | No.2366 登校 |
ユーザー | shobonvip |
提出日時 | 2023-06-30 04:40:50 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 1,809 bytes |
コンパイル時間 | 262 ms |
コンパイル使用メモリ | 87,264 KB |
実行使用メモリ | 340,172 KB |
最終ジャッジ日時 | 2023-09-22 17:38:56 |
合計ジャッジ時間 | 56,902 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 152 ms
340,172 KB |
testcase_01 | AC | 77 ms
71,180 KB |
testcase_02 | AC | 103 ms
76,096 KB |
testcase_03 | AC | 174 ms
78,732 KB |
testcase_04 | AC | 77 ms
71,240 KB |
testcase_05 | AC | 120 ms
77,036 KB |
testcase_06 | AC | 173 ms
79,044 KB |
testcase_07 | AC | 187 ms
78,704 KB |
testcase_08 | AC | 217 ms
79,664 KB |
testcase_09 | AC | 226 ms
79,552 KB |
testcase_10 | AC | 123 ms
77,608 KB |
testcase_11 | AC | 139 ms
78,216 KB |
testcase_12 | TLE | - |
testcase_13 | AC | 3,796 ms
149,628 KB |
testcase_14 | AC | 3,948 ms
155,956 KB |
testcase_15 | TLE | - |
testcase_16 | AC | 3,955 ms
147,672 KB |
testcase_17 | TLE | - |
testcase_18 | AC | 3,879 ms
158,168 KB |
testcase_19 | AC | 3,969 ms
150,620 KB |
testcase_20 | AC | 3,972 ms
152,160 KB |
testcase_21 | AC | 3,856 ms
151,964 KB |
testcase_22 | AC | 3,335 ms
148,664 KB |
testcase_23 | AC | 2,753 ms
196,824 KB |
testcase_24 | AC | 2,761 ms
196,724 KB |
testcase_25 | TLE | - |
testcase_26 | -- | - |
ソースコード
# これ解くのに 998244353 時間かかった! # ぼくが弱いだけで, ★3.0 …かも? # よく考えると T が大きければ何もする必要はないし, 時を戻すときも N+M-1 以上時を戻す必要もない. # そう思うと, 時間の初期値を200として, 時間を400までもつ. # -> 時間は 0 より戻れないし, 400 より進めない. でもそれでいい. # その間で, (時間, 位置) の拡張 dijkstra 法を行うとよい. # O((N+M)NM log(NM)) になる. # は python で優先度付きキューが小さい順なの忘れてた おわりだ` # あとのコードでは直してた c-1 が c になってた import heapq n, m, k, t = map(int,input().split()) ikeru = [[[] for j in range(m)] for i in range(n)] for i in range(n): for j in range(m): for x, y in [(-1, 0), (1, 0), (0, 1), (0, -1)]: if 0 <= i + x < n and 0 <= j + y < m: ikeru[i][j].append((i + x, j + y)) modoru = [[(-1,-1) for j in range(m)] for i in range(n)] for i in range(k): a, b, c, d = map(int,input().split()) a -= 1 b -= 1 modoru[a][b] = (c, d) d = [[[10 ** 18] * 601 for i in range(m)] for i in range(n)] d[0][0][200] = 0 pq = [(d[0][0][200], 0, 0, 200)] while pq: tmp, a, b, nowt = heapq.heappop(pq) if tmp > d[a][b][nowt]: continue for x, y in ikeru[a][b]: dist = tmp if dist < d[x][y][min(nowt+1, 600)]: d[x][y][min(nowt+1, 600)] = dist heapq.heappush(pq, (dist, x, y, min(nowt+1, 600))) if modoru[a][b][0] == -1: continue c, dd = modoru[a][b] dist = tmp + dd if dist < d[a][b][max(0, nowt-c+1)]: d[a][b][max(0, nowt-c+1)] = dist heapq.heappush(pq, (dist, a, b, max(0, nowt-c+1))) ans = 10 ** 18 for ts in range(601): if ts - 200 > t: continue ans = min(ans, d[n-1][m-1][ts]) if ans == 10 ** 18: print(-1) else: print(ans)