結果
問題 | No.2366 登校 |
ユーザー | shobonvip |
提出日時 | 2023-06-30 04:43:43 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,040 bytes |
コンパイル時間 | 488 ms |
コンパイル使用メモリ | 86,764 KB |
実行使用メモリ | 111,476 KB |
最終ジャッジ日時 | 2023-09-22 05:11:11 |
合計ジャッジ時間 | 17,432 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 139 ms
77,812 KB |
testcase_01 | AC | 76 ms
71,208 KB |
testcase_02 | AC | 93 ms
76,036 KB |
testcase_03 | AC | 177 ms
78,480 KB |
testcase_04 | AC | 77 ms
71,228 KB |
testcase_05 | AC | 122 ms
77,532 KB |
testcase_06 | AC | 173 ms
78,200 KB |
testcase_07 | AC | 183 ms
78,568 KB |
testcase_08 | AC | 207 ms
79,208 KB |
testcase_09 | AC | 204 ms
79,192 KB |
testcase_10 | AC | 98 ms
76,012 KB |
testcase_11 | AC | 130 ms
77,456 KB |
testcase_12 | AC | 892 ms
91,760 KB |
testcase_13 | AC | 892 ms
92,936 KB |
testcase_14 | AC | 914 ms
92,568 KB |
testcase_15 | AC | 926 ms
92,724 KB |
testcase_16 | WA | - |
testcase_17 | AC | 937 ms
93,320 KB |
testcase_18 | AC | 946 ms
92,216 KB |
testcase_19 | AC | 938 ms
93,236 KB |
testcase_20 | AC | 930 ms
92,964 KB |
testcase_21 | WA | - |
testcase_22 | AC | 709 ms
91,024 KB |
testcase_23 | WA | - |
testcase_24 | AC | 378 ms
101,496 KB |
testcase_25 | AC | 1,428 ms
111,476 KB |
testcase_26 | AC | 1,469 ms
109,964 KB |
ソースコード
import heapq n, m, k, t = map(int,input().split()) 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) tmax = 401 d = [10 ** 18] * n * m * tmax d[200] = 0 pq = [(d[200], 200)] r1 = m * tmax while pq: tmp, nowv = heapq.heappop(pq) fnv = nowv nowt = nowv % tmax nowv //= tmax b = nowv % m a = nowv // m if tmp > d[fnv]: continue for xx, yy in [(-1, 0), (1, 0), (0, 1), (0, -1)]: x = a + xx y = b + yy if 0 <= x < n and 0 <= y < m: dist = tmp targ = x*r1 + y*tmax + min(nowt+1, tmax-1) if dist < d[targ]: d[targ] = dist heapq.heappush(pq, (dist, targ)) if modoru[a][b][0] == -1: continue c, dd = modoru[a][b] dist = tmp + dd targ = a*r1 + b*tmax + max(0, nowt-c+1) if dist < d[targ]: d[targ] = dist heapq.heappush(pq, (dist, targ)) ans = 10 ** 18 for ts in range(tmax): if ts - 200 >= t: continue ans = min(ans, d[(n-1)*r1 + (m-1)*tmax + ts]) if ans == 10 ** 18: print(-1) else: print(ans)