結果
問題 | No.34 砂漠の行商人 |
ユーザー | tktk_snsn |
提出日時 | 2020-12-24 04:39:51 |
言語 | PyPy3 (7.3.15) |
結果 |
MLE
|
実行時間 | - |
コード長 | 934 bytes |
コンパイル時間 | 195 ms |
コンパイル使用メモリ | 81,764 KB |
実行使用メモリ | 719,784 KB |
最終ジャッジ日時 | 2023-10-21 15:34:02 |
合計ジャッジ時間 | 13,144 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge9 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 40 ms
53,440 KB |
testcase_01 | MLE | - |
testcase_02 | AC | 141 ms
110,368 KB |
testcase_03 | AC | 64 ms
87,580 KB |
testcase_04 | AC | 669 ms
278,044 KB |
testcase_05 | AC | 762 ms
345,004 KB |
testcase_06 | AC | 330 ms
228,292 KB |
testcase_07 | AC | 1,189 ms
478,884 KB |
testcase_08 | MLE | - |
testcase_09 | MLE | - |
testcase_10 | -- | - |
testcase_11 | -- | - |
testcase_12 | -- | - |
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 | -- | - |
ソースコード
import heapq import sys input = sys.stdin.buffer.readline sys.setrecursionlimit(10 ** 7) inf = 100000 U = 10009 DX = (-1, 0, 1, 0, -1, -1, 1, 1) DY = (0, 1, 0, -1, -1, 1, -1, 1) DX = DX[:4] DY = DY[:4] N, V, sy, sx, gy, gx = map(int, input().split()) L = tuple(tuple(map(int, input().split())) for _ in range(N)) sy -= 1 sx -= 1 gx -= 1 gy -= 1 dist = [[[inf] * (U + 1) for _ in range(N)] for _ in range(N)] dist[0][0][0] = 0 que = [(0, 0, sx, sy)] while que: d, hp, x, y = heapq.heappop(que) if (x, y) == (gx, gy): print(dist[gx][gy][hp]) exit() if dist[x][y][hp] < d: continue for dx, dy in zip(DX, DY): nx = x + dx ny = y + dy if 0 <= nx < N and 0 <= ny < N and hp + L[nx][ny] < V: nhp = hp + L[nx][ny] if dist[nx][ny][nhp] > d + 1: dist[nx][ny][nhp] = d + 1 heapq.heappush(que, (d+1, nhp, nx, ny)) print(-1)