結果

問題 No.20 砂漠のオアシス
コンテスト
ユーザー ああ
提出日時 2026-05-20 20:05:40
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
WA  
実行時間 -
コード長 689 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 224 ms
コンパイル使用メモリ 85,120 KB
実行使用メモリ 85,880 KB
最終ジャッジ日時 2026-05-20 20:05:45
合計ジャッジ時間 4,995 ms
ジャッジサーバーID
(参考情報)
judge1_1 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 17 WA * 4
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

import heapq

def aa(i,j):
    global n
    hq=[];heapq.heappush(hq,(l[i][j],i,j))
    res=[[1<<60]*n for i in range(n)];res[i][j]=l[i][j]
    while hq:
        q,w,e=heapq.heappop(hq)
        if res[w][e]<q:
            continue
        for i,j in [(1,0),(-1,0),(0,1),(0,-1)]:
            i,j=i+w,j+e
            if 0<=i<n and 0<=j<n and res[i][j]>q+l[i][j]:
                res[i][j]=q+l[i][j]
                heapq.heappush(hq,(res[i][j],i,j))
    return res

n,v,ox,oy=map(int,input().split());ox-=1;oy-=1
l=[list(map(int,input().split())) for i in range(n)]
x=aa(0,0);y=aa(n-1,n-1)
ans="NO"
if x[n-1][n-1]<v or (ox>=0 and (v-x[ox][oy])*2+l[ox][oy]>y[ox][oy]):
    ans="YES"
print(ans)
0