結果
問題 | No.20 砂漠のオアシス |
ユーザー | yuyyuyu |
提出日時 | 2015-08-01 13:32:56 |
言語 | PyPy2 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 753 bytes |
コンパイル時間 | 325 ms |
コンパイル使用メモリ | 77,056 KB |
実行使用メモリ | 86,196 KB |
最終ジャッジ日時 | 2024-04-21 06:40:13 |
合計ジャッジ時間 | 7,796 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 75 ms
75,776 KB |
testcase_01 | AC | 78 ms
75,520 KB |
testcase_02 | AC | 78 ms
75,560 KB |
testcase_03 | AC | 115 ms
78,220 KB |
testcase_04 | AC | 138 ms
79,124 KB |
testcase_05 | AC | 123 ms
78,720 KB |
testcase_06 | AC | 138 ms
79,232 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 | -- | - |
ソースコード
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] not in que: que.append([nx,ny,count]) maxV[ny][nx]=nv else: print 'NO'