結果

問題 No.20 砂漠のオアシス
ユーザー TawaraTawara
提出日時 2015-12-30 02:26:43
言語 Python2
(2.7.18)
結果
WA  
実行時間 -
コード長 543 bytes
コンパイル時間 281 ms
コンパイル使用メモリ 7,040 KB
実行使用メモリ 9,600 KB
最終ジャッジ日時 2024-04-21 06:47:54
合計ジャッジ時間 2,305 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 11 ms
6,812 KB
testcase_01 WA -
testcase_02 AC 11 ms
6,944 KB
testcase_03 AC 31 ms
6,940 KB
testcase_04 AC 19 ms
6,940 KB
testcase_05 WA -
testcase_06 AC 140 ms
8,064 KB
testcase_07 WA -
testcase_08 AC 137 ms
8,064 KB
testcase_09 AC 137 ms
8,064 KB
testcase_10 AC 12 ms
6,944 KB
testcase_11 WA -
testcase_12 AC 15 ms
6,940 KB
testcase_13 AC 16 ms
6,944 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 28 ms
6,940 KB
testcase_18 WA -
testcase_19 AC 35 ms
6,944 KB
testcase_20 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

from heapq import heappop,heappush
I=lambda:map(int,raw_input().split())
N,V,x,y=I();s=(0,0);o=(x-1,y-1);g=(N-1,N-1)
L=[I()for i in range(N)];dxy=((1,0),(0,1),(-1,0),(0,-1))
def d(s,g):
	Q=[];D=[N*[100000]for i in range(N)]
	D[s[1]][s[0]]=0
	heappush(Q,(0,(0,0)))
	while Q:
		c,h=heappop(Q)
		if h == g:break
		for dx,dy in dxy:
			nx=h[0]+dx;ny=h[1]+dy
			if 0<=nx<N and 0<=ny<N and c+L[ny][nx]<D[ny][nx]:
				D[ny][nx]=nc=c+L[ny][nx];heappush(Q,(nc,(nx,ny)))
	return D[g[1]][g[0]]
print["NO","YES"][V>d(s,g)or(x*y==0 and(V-d(s,o))*2>d(o,g))]
0