結果

問題 No.34 砂漠の行商人
ユーザー convexineqconvexineq
提出日時 2021-01-17 02:55:57
言語 PyPy3
(7.3.13)
結果
MLE  
実行時間 -
コード長 651 bytes
コンパイル時間 360 ms
コンパイル使用メモリ 87,052 KB
実行使用メモリ 552,884 KB
最終ジャッジ日時 2023-08-19 08:07:56
合計ジャッジ時間 16,277 ms
ジャッジサーバーID
(参考情報)
judge11 / judge9
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 80 ms
75,784 KB
testcase_01 AC 88 ms
77,072 KB
testcase_02 AC 104 ms
83,828 KB
testcase_03 AC 85 ms
77,184 KB
testcase_04 AC 169 ms
118,020 KB
testcase_05 AC 176 ms
128,268 KB
testcase_06 AC 130 ms
105,544 KB
testcase_07 AC 230 ms
153,016 KB
testcase_08 AC 280 ms
182,876 KB
testcase_09 AC 1,771 ms
351,984 KB
testcase_10 AC 333 ms
227,504 KB
testcase_11 MLE -
testcase_12 AC 155 ms
116,512 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 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

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 = 5000
d = [[[INF]*1801 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)
0