結果
問題 | No.34 砂漠の行商人 |
ユーザー | brthyyjp |
提出日時 | 2021-11-03 02:51:44 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 810 bytes |
コンパイル時間 | 208 ms |
コンパイル使用メモリ | 82,160 KB |
実行使用メモリ | 254,024 KB |
最終ジャッジ日時 | 2024-04-20 15:20:22 |
合計ジャッジ時間 | 14,676 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 39 ms
54,248 KB |
testcase_01 | AC | 39 ms
52,836 KB |
testcase_02 | AC | 87 ms
76,408 KB |
testcase_03 | AC | 40 ms
53,424 KB |
testcase_04 | AC | 296 ms
79,056 KB |
testcase_05 | AC | 282 ms
78,588 KB |
testcase_06 | AC | 90 ms
76,660 KB |
testcase_07 | AC | 456 ms
80,916 KB |
testcase_08 | AC | 619 ms
84,288 KB |
testcase_09 | AC | 3,306 ms
192,900 KB |
testcase_10 | AC | 421 ms
82,744 KB |
testcase_11 | AC | 1,181 ms
93,920 KB |
testcase_12 | AC | 176 ms
77,712 KB |
testcase_13 | TLE | - |
testcase_14 | -- | - |
testcase_15 | -- | - |
testcase_16 | -- | - |
testcase_17 | -- | - |
testcase_18 | -- | - |
testcase_19 | -- | - |
testcase_20 | -- | - |
testcase_21 | -- | - |
testcase_22 | -- | - |
testcase_23 | -- | - |
testcase_24 | -- | - |
testcase_25 | -- | - |
ソースコード
import sys import io, os input = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline n, v, sx, sy, gx, gy = map(int, input().split()) sx, sy = sx-1, sy-1 gx, gy = gx-1, gy-1 L = [] for i in range(n): l = list(map(int, input().split())) L += l s = sy*n+sx g = gy*n+gx import heapq hq = [(0, v, s)] HP = [0]*(n*n) heapq.heapify(hq) visit = [False]*(n*n) while hq: time, hp, i = heapq.heappop(hq) y, x = divmod(i, n) if i == g: print(time) exit() for dy, dx in (-1, 0), (1, 0), (0, 1), (0, -1): ny, nx = y+dy, x+dx if 0 <= ny < n and 0 <= nx < n: j = ny*n+nx if hp-L[j] <= 0: continue if hp-L[j] > HP[j]: HP[j] = hp-L[j] heapq.heappush(hq, (time+1, hp-L[j], j)) print(-1)