結果

問題 No.34 砂漠の行商人
ユーザー yaoshimaxyaoshimax
提出日時 2015-02-15 20:38:26
言語 Python2
(2.7.18)
結果
TLE  
実行時間 -
コード長 662 bytes
コンパイル時間 84 ms
コンパイル使用メモリ 6,528 KB
実行使用メモリ 54,760 KB
最終ジャッジ日時 2023-09-06 01:17:49
合計ジャッジ時間 7,573 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 13 ms
13,420 KB
testcase_01 AC 13 ms
6,352 KB
testcase_02 AC 23 ms
6,228 KB
testcase_03 AC 12 ms
6,204 KB
testcase_04 AC 580 ms
7,172 KB
testcase_05 TLE -
testcase_06 TLE -
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 #

from collections import deque
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=deque([(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.popleft()
    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