結果

問題 No.34 砂漠の行商人
ユーザー roiti46roiti46
提出日時 2015-02-22 18:47:04
言語 Python2
(2.7.18)
結果
TLE  
実行時間 -
コード長 543 bytes
コンパイル時間 151 ms
コンパイル使用メモリ 6,712 KB
実行使用メモリ 15,648 KB
最終ジャッジ日時 2023-09-06 02:59:28
合計ジャッジ時間 16,329 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 12 ms
5,888 KB
testcase_01 AC 11 ms
6,044 KB
testcase_02 AC 19 ms
6,072 KB
testcase_03 AC 11 ms
5,864 KB
testcase_04 AC 128 ms
6,156 KB
testcase_05 AC 337 ms
6,668 KB
testcase_06 AC 39 ms
6,188 KB
testcase_07 AC 639 ms
6,600 KB
testcase_08 AC 1,125 ms
6,904 KB
testcase_09 TLE -
testcase_10 AC 384 ms
6,900 KB
testcase_11 AC 1,264 ms
6,968 KB
testcase_12 AC 70 ms
6,280 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
    if HP[y][x] >= v: continue
    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]:
            que.append([nx,ny,v-L[ny][nx],d+1])
else:
    print -1
0