結果

問題 No.20 砂漠のオアシス
ユーザー tnodinotnodino
提出日時 2022-02-12 15:18:43
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 908 bytes
コンパイル時間 119 ms
コンパイル使用メモリ 11,040 KB
実行使用メモリ 13,512 KB
最終ジャッジ日時 2023-09-11 02:54:47
合計ジャッジ時間 8,516 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 17 ms
8,080 KB
testcase_01 AC 17 ms
8,228 KB
testcase_02 AC 19 ms
8,088 KB
testcase_03 AC 97 ms
8,080 KB
testcase_04 AC 525 ms
8,212 KB
testcase_05 AC 297 ms
8,812 KB
testcase_06 AC 694 ms
8,740 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