結果

問題 No.34 砂漠の行商人
ユーザー yaoshimaxyaoshimax
提出日時 2015-02-15 19:49:27
言語 Python2
(2.7.18)
結果
TLE  
実行時間 -
コード長 622 bytes
コンパイル時間 427 ms
コンパイル使用メモリ 6,640 KB
実行使用メモリ 16,868 KB
最終ジャッジ日時 2023-09-06 01:17:25
合計ジャッジ時間 8,227 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 11 ms
5,844 KB
testcase_01 AC 11 ms
5,948 KB
testcase_02 AC 22 ms
5,868 KB
testcase_03 AC 11 ms
5,972 KB
testcase_04 AC 948 ms
6,672 KB
testcase_05 TLE -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
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 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

N,V,Sy,Sx,Gy,Gx = map(int,raw_input().split())
L=[]
for i in range(N):
    line = map(int,raw_input().split())
    L.append(line)

que=[(0,Sx-1,Sy-1,V)]

arrived=[[0 for i in range(N)]for j in range(N)]
dxs=[1,0,-1,0]
dys=[0,1,0,-1]
while len(que)!=0:
    dist,x,y,v = que.pop(0)
    if arrived[x][y]>v:
        continue
    arrived[x][y]=v
    #print dist,y,x,v
    if (x,y)==(Gx-1,Gy-1):
        print dist
        exit()
    for dx,dy in zip(dxs,dys):
        nx,ny=x+dx,y+dy
        if nx>=0 and ny >= 0 and nx <N and ny <N and arrived[nx][ny]<v-L[nx][ny] :
            que.append((dist+1,nx,ny,v-L[nx][ny]))
print -1
0