結果

問題 No.34 砂漠の行商人
ユーザー roiti46roiti46
提出日時 2015-02-22 18:51:27
言語 Python2
(2.7.18)
結果
TLE  
実行時間 -
コード長 549 bytes
コンパイル時間 60 ms
コンパイル使用メモリ 6,712 KB
実行使用メモリ 8,760 KB
最終ジャッジ日時 2023-09-06 03:00:16
合計ジャッジ時間 12,095 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 12 ms
5,944 KB
testcase_01 AC 12 ms
5,984 KB
testcase_02 AC 19 ms
6,004 KB
testcase_03 AC 11 ms
5,868 KB
testcase_04 AC 107 ms
6,072 KB
testcase_05 AC 234 ms
6,120 KB
testcase_06 AC 35 ms
5,916 KB
testcase_07 AC 440 ms
6,524 KB
testcase_08 AC 716 ms
6,452 KB
testcase_09 AC 2,464 ms
7,248 KB
testcase_10 AC 260 ms
6,472 KB
testcase_11 AC 780 ms
6,520 KB
testcase_12 AC 56 ms
6,092 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 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

dxy = zip([1,0,-1,0],[0,1,0,-1])
N,V,Sx,Sy,Gx,Gy = map(int,raw_input().split())
Sx,Sy,Gx,Gy = Sx-1,Sy-1,Gx-1,Gy-1
L = [map(int,raw_input().split()) for i in xrange(N)]
HP = [[0]*N for i in xrange(N)]
que = [[Sx,Sy,V,0]]
while que:
    x,y,v,d = que.pop(0)
    if (x,y) == (Gx,Gy):
        print d
        break
    HP[y][x] = v
    for dx,dy in dxy:
        nx,ny = x+dx,y+dy
        if 0 <= nx < N and 0 <= ny < N and v-L[ny][nx] > HP[ny][nx]:
            HP[ny][nx] = v-L[ny][nx]
            que.append([nx,ny,v-L[ny][nx],d+1])
else:
    print -1
0