結果
| 問題 |
No.20 砂漠のオアシス
|
| ユーザー |
yuyyuyu
|
| 提出日時 | 2015-08-01 16:39:43 |
| 言語 | PyPy2 (7.3.15) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 783 bytes |
| コンパイル時間 | 120 ms |
| コンパイル使用メモリ | 77,116 KB |
| 実行使用メモリ | 99,292 KB |
| 最終ジャッジ日時 | 2024-10-13 05:23:23 |
| 合計ジャッジ時間 | 7,551 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 7 TLE * 1 -- * 13 |
ソースコード
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]]
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'
yuyyuyu