結果
| 問題 | No.20 砂漠のオアシス | 
| コンテスト | |
| ユーザー |  titia | 
| 提出日時 | 2021-11-07 01:39:21 | 
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) | 
| 結果 | 
                                WA
                                 
                             | 
| 実行時間 | - | 
| コード長 | 1,017 bytes | 
| コンパイル時間 | 378 ms | 
| コンパイル使用メモリ | 12,672 KB | 
| 実行使用メモリ | 13,056 KB | 
| 最終ジャッジ日時 | 2024-11-08 01:29:48 | 
| 合計ジャッジ時間 | 3,236 ms | 
| ジャッジサーバーID (参考情報) | judge4 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 16 WA * 5 | 
ソースコード
import heapq
N,V,cx,cy=map(int,input().split())
MAP=[list(map(int,input().split())) for i in range(N)]
cx-=1
cy-=1
DP1=[[0]*N for i in range(N)]
DP2=[[0]*N for i in range(N)]
DP1[0][0]=V
Q=[(-V,0,0,1)]
while Q:
    hp,x,y,c=heapq.heappop(Q)
    hp=-hp
    if c==1:
        for z,w in [(x+1,y),(x-1,y),(x,y+1),(x,y-1)]:
            if 0<=z<N and 0<=w<N:
                if DP1[z][w]<hp-MAP[z][w]:
                    DP1[z][w]=hp-MAP[z][w]
                    heapq.heappush(Q,(-DP1[z][w],z,w,1))
                    if z==cx and w==cy and DP2[z][w]<(hp-MAP[z][w])*2:
                        DP2[z][w]=(hp-MAP[z][w])*2
                        heapq.heappush(Q,(-DP2[z][w],z,w,2))
    else:
        for z,w in [(x+1,y),(x-1,y),(x,y+1),(x,y-1)]:
            if 0<=z<N and 0<=w<N:
                if DP2[z][w]<hp-MAP[z][w]:
                    DP2[z][w]=hp-MAP[z][w]
                    heapq.heappush(Q,(-DP2[z][w],z,w,2))
if DP1[N-1][N-1]>0 or DP2[N-1][N-1]>0:
    print("YES")
else:
    print("NO")
        
            
            
            
        