結果
問題 | No.34 砂漠の行商人 |
ユーザー | convexineq |
提出日時 | 2021-01-17 02:54:42 |
言語 | PyPy3 (7.3.15) |
結果 |
MLE
|
実行時間 | - |
コード長 | 652 bytes |
コンパイル時間 | 334 ms |
コンパイル使用メモリ | 86,784 KB |
実行使用メモリ | 574,704 KB |
最終ジャッジ日時 | 2023-08-19 08:04:10 |
合計ジャッジ時間 | 15,857 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 77 ms
75,980 KB |
testcase_01 | AC | 89 ms
77,152 KB |
testcase_02 | AC | 110 ms
84,416 KB |
testcase_03 | AC | 94 ms
77,960 KB |
testcase_04 | AC | 187 ms
119,284 KB |
testcase_05 | AC | 195 ms
133,536 KB |
testcase_06 | AC | 131 ms
108,188 KB |
testcase_07 | AC | 240 ms
163,732 KB |
testcase_08 | AC | 291 ms
192,416 KB |
testcase_09 | AC | 1,795 ms
367,288 KB |
testcase_10 | AC | 333 ms
242,056 KB |
testcase_11 | MLE | - |
testcase_12 | AC | 158 ms
120,156 KB |
testcase_13 | MLE | - |
testcase_14 | -- | - |
testcase_15 | -- | - |
testcase_16 | -- | - |
testcase_17 | -- | - |
testcase_18 | -- | - |
testcase_19 | -- | - |
testcase_20 | -- | - |
testcase_21 | -- | - |
testcase_22 | -- | - |
testcase_23 | -- | - |
testcase_24 | -- | - |
testcase_25 | -- | - |
ソースコード
n,v,sy,sx,gy,gx = map(int,input().split()) b = [list(map(int,input().split())) for _ in range(n)] v = min(v,1800) INF = 10**9 d = [[[INF]*2001 for _ in range(n)] for _ in range(n)] d[sx-1][sy-1][v] = 0 gx -= 1; gy -= 1 from collections import deque q = deque([(0,v,sx-1,sy-1)]) while q: dv,v,x,y = q.popleft() if x==gx and y==gy: print(dv) exit() for nx,ny in [(x+1,y),(x-1,y),(x,y-1),(x,y+1)]: if 0 <= nx < n and 0 <= ny < n: nv = v - b[nx][ny] if nv <= 0: continue if dv+1 < d[nx][ny][nv]: d[nx][ny][nv] = dv+1 q.append((dv+1,nv,nx,ny)) print(-1)