結果

問題 No.20 砂漠のオアシス
ユーザー yuyyuyuyuyyuyu
提出日時 2015-08-01 16:45:29
言語 PyPy2
(7.3.15)
結果
TLE  
実行時間 -
コード長 774 bytes
コンパイル時間 225 ms
コンパイル使用メモリ 76,448 KB
実行使用メモリ 80,572 KB
最終ジャッジ日時 2024-04-21 06:41:12
合計ジャッジ時間 7,748 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 69 ms
75,552 KB
testcase_01 AC 67 ms
75,540 KB
testcase_02 AC 68 ms
75,804 KB
testcase_03 AC 135 ms
78,400 KB
testcase_04 AC 182 ms
78,508 KB
testcase_05 AC 141 ms
80,572 KB
testcase_06 AC 176 ms
79,528 KB
testcase_07 TLE -
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=[]
L = [map(int,raw_input().split()) for i in xrange(N)]
dxdy=zip([-1,0,1,0],[0,-1,0,1])
que=[[0,0]]
visited=[]
Vcount=[[[-1,-1]]*N for _ in xrange(N)]
Vcount[0][0]=[V,1]
while que:#bfs
    cx,cy=que.pop(0)
    [v,count]=Vcount[cy][cx]
    for dx,dy in dxdy:
        nx,ny=cx+dx,cy+dy
        if not(0<=nx<N and 0<=ny<N):continue# in field?
        nv=v-L[ny][nx]
        if nv<=0:continue#death
        if nx==N-1 and ny==N-1 and nv>0:
            print 'YES'
            exit()
        if cx==ox and cy==oy and count>0:#oasis
            nv=nv*2
            count-=1
        if Vcount[ny][nx][0]<nv:
            Vcount[ny][nx]=[nv,count]
            if [nx,ny] not in que:
                que.append([nx,ny])
print 'NO'
0