結果

問題 No.34 砂漠の行商人
ユーザー TawaraTawara
提出日時 2015-12-30 00:07:11
言語 PyPy2
(7.3.15)
結果
MLE  
実行時間 -
コード長 563 bytes
コンパイル時間 1,521 ms
コンパイル使用メモリ 77,068 KB
実行使用メモリ 820,112 KB
最終ジャッジ日時 2023-10-19 12:28:15
合計ジャッジ時間 7,089 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 93 ms
77,696 KB
testcase_01 AC 94 ms
77,696 KB
testcase_02 MLE -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
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 #

from Queue import deque
N,V,sx,sy,gx,gy=map(int,raw_input().split())
sx -= 1; sy -= 1; gx -= 1; gy -= 1
L = [map(int,raw_input().split()) for i in xrange(N)]
dxy = ((1,0),(0,1),(-1,0),(0,-1))
Q = deque([(sx,sy,V,0)])
visited = [[0]*N for i in xrange(N)]
visited[sy][sx] = V
while Q:
	hx,hy,v,c = Q.popleft()
	if hx == gx and hy == gy: print c; break
	for dx,dy in dxy:
		nx = hx + dx; ny = hy + dy
		if 0 <= nx < N and 0 <= ny < N:
			nv = v - L[ny][nx]
			if nv > 0 and visited[ny][nx] <= nv:
				visited[ny][nx] = nv
				Q.append((nx,ny,nv,c+1))
else:
	print -1
0