結果

問題 No.20 砂漠のオアシス
ユーザー tnodinotnodino
提出日時 2022-02-12 15:18:14
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 908 bytes
コンパイル時間 633 ms
コンパイル使用メモリ 86,676 KB
実行使用メモリ 84,888 KB
最終ジャッジ日時 2023-09-11 02:54:12
合計ジャッジ時間 10,380 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
71,216 KB
testcase_01 AC 79 ms
71,116 KB
testcase_02 AC 129 ms
77,756 KB
testcase_03 AC 242 ms
78,260 KB
testcase_04 AC 846 ms
78,436 KB
testcase_05 AC 560 ms
78,616 KB
testcase_06 AC 1,076 ms
78,900 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 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

from heapq import heappop, heappush
def Dijkstra(H, W, L, sx, sy, gx, gy, V, Ox, Oy):
    def _Dijkstra():
        while heap:
            C,x,y = heappop(heap)
            if Cost[x][y] >= C:
                continue
            Cost[x][y] = C
            for i in range(len(dx)):
                nx,my = x + dx[i], y + dy[i]
                if nx < 0 or H <= nx or my < 0 or W <= my:
                    continue
                heappush(heap, (C - L[nx][my], nx, my))
    INF = -1
    dx = [0, 0, -1, 1]
    dy = [-1, 1, 0, 0]
    Cost = [[INF] * W for _ in range(H)]
    heap = []
    heappush(heap, (V, sx, sy))
    _Dijkstra()
    heappush(heap, (Cost[Ox][Oy] * 2, Ox, Oy))
    _Dijkstra()
    return Cost[gx][gy]

N,V,Oy,Ox = map(int,input().split())
L = [list(map(int,input().split())) for _ in range(N)]
if Dijkstra(N, N, L, 0, 0, N-1, N-1, V, Ox-1, Oy-1) > 0:
    print('YES')
else:
    print('NO')
0