結果

問題 No.20 砂漠のオアシス
ユーザー yuyyuyuyuyyuyu
提出日時 2015-08-01 13:38:52
言語 PyPy2
(7.3.15)
結果
WA  
実行時間 -
コード長 770 bytes
コンパイル時間 267 ms
コンパイル使用メモリ 76,964 KB
実行使用メモリ 80,684 KB
最終ジャッジ日時 2024-04-21 06:40:36
合計ジャッジ時間 3,521 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
75,656 KB
testcase_01 AC 78 ms
75,680 KB
testcase_02 AC 76 ms
75,632 KB
testcase_03 AC 96 ms
78,112 KB
testcase_04 AC 110 ms
79,264 KB
testcase_05 AC 117 ms
78,944 KB
testcase_06 AC 110 ms
78,880 KB
testcase_07 WA -
testcase_08 AC 122 ms
78,752 KB
testcase_09 AC 201 ms
79,380 KB
testcase_10 AC 74 ms
75,432 KB
testcase_11 AC 74 ms
75,644 KB
testcase_12 AC 102 ms
78,604 KB
testcase_13 AC 102 ms
78,400 KB
testcase_14 AC 116 ms
79,160 KB
testcase_15 AC 106 ms
79,012 KB
testcase_16 WA -
testcase_17 AC 112 ms
79,016 KB
testcase_18 WA -
testcase_19 AC 116 ms
79,120 KB
testcase_20 WA -
権限があれば一括ダウンロードができます

ソースコード

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,1]]
visited=[]
maxV=[[-1]*N for _ in xrange(N)]
maxV[0][0]=V
while que:#bfs
    cx,cy,count=que.pop(0)
    v=maxV[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 maxV[ny][nx]<nv and ([nx,ny,0] or [nx,ny,1] not in que):
            que.append([nx,ny,count])
            maxV[ny][nx]=nv
else:
    print 'NO'
0