結果

問題 No.20 砂漠のオアシス
ユーザー convexineqconvexineq
提出日時 2021-01-17 02:17:46
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 716 bytes
コンパイル時間 609 ms
コンパイル使用メモリ 86,996 KB
実行使用メモリ 82,476 KB
最終ジャッジ日時 2023-08-19 06:40:53
合計ジャッジ時間 4,480 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,596 KB
testcase_01 WA -
testcase_02 AC 69 ms
71,412 KB
testcase_03 AC 100 ms
77,904 KB
testcase_04 AC 101 ms
77,772 KB
testcase_05 WA -
testcase_06 AC 211 ms
78,976 KB
testcase_07 WA -
testcase_08 AC 219 ms
79,244 KB
testcase_09 AC 226 ms
78,960 KB
testcase_10 AC 74 ms
71,672 KB
testcase_11 AC 71 ms
71,600 KB
testcase_12 AC 106 ms
77,664 KB
testcase_13 AC 111 ms
77,940 KB
testcase_14 AC 117 ms
78,020 KB
testcase_15 AC 113 ms
77,952 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 124 ms
78,204 KB
testcase_20 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

n,v,sx,sy = map(int,input().split())
b = [list(map(int,input().split())) for _ in range(n)]

def dijkstra(x,y,flag):
    d = [[-1]*n for _ in range(n)]
    d[x][y] = 0
    from heapq import heappush, heappop
    q = [(0,x,y)]
    while q:
        dv,x,y = heappop(q)
        for nx,ny in [(x+1,y),(x-1,y),(x,y-1),(x,y+1)]:
            if 0 <= nx < n and 0 <= ny < n and d[nx][ny]==-1:
                d[nx][ny] = dv + b[nx][ny]
                heappush(q,(dv + b[nx][ny],nx,ny))
    if flag:
        return v > d[-1][-1]
    else:
        return v > d[0][0] + d[sx][sy] and (v - d[0][0] - d[sx][sy])*2 > d[-1][-1]

    return d            

print("YES" if dijkstra(0,0,1) or (sx and dijkstra(sx-1,sy-1,0)) else "NO")
0