結果

問題 No.20 砂漠のオアシス
ユーザー yuyyuyuyuyyuyu
提出日時 2015-08-01 10:32:29
言語 PyPy2
(7.3.15)
結果
WA  
実行時間 -
コード長 588 bytes
コンパイル時間 1,694 ms
コンパイル使用メモリ 76,728 KB
実行使用メモリ 87,972 KB
最終ジャッジ日時 2024-04-21 06:39:25
合計ジャッジ時間 8,941 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 70 ms
75,392 KB
testcase_02 AC 69 ms
75,520 KB
testcase_03 AC 115 ms
78,108 KB
testcase_04 WA -
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 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

N,V,ox,oy=map(int,raw_input().split())
ox-=1;oy-=1
L=[]
for _ in xrange(N):
    L.append(map(int,raw_input().split()))
dxdy=zip([-1,0,1,0],[0,-1,0,1])
que=[[0,0,V]]
visited=[]
while que:
    cx,cy,v=que.pop(0)
    for dx,dy in dxdy:
        nx,ny,nv=cx+dx,cy+dy,v-L[cy][cx]
        if nx==N-1 and ny==N-1 and nv>0:
            print 'YES'
            exit()
        if not(0<=nx<N and 0<=ny<N):continue
        if cx==ox and cy==oy:
            nv=nv*2
        if nv>0 and [nx,ny] not in visited:
            que.append([nx,ny,nv])
            visited.append([nx,ny])
else:
    print 'NO'
0