結果

問題 No.20 砂漠のオアシス
ユーザー sotanishysotanishy
提出日時 2021-03-16 22:25:39
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 766 bytes
コンパイル時間 332 ms
コンパイル使用メモリ 86,952 KB
実行使用メモリ 79,936 KB
最終ジャッジ日時 2023-08-08 12:10:00
合計ジャッジ時間 4,398 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 67 ms
71,408 KB
testcase_01 AC 72 ms
71,196 KB
testcase_02 AC 73 ms
71,412 KB
testcase_03 AC 148 ms
78,720 KB
testcase_04 AC 137 ms
78,480 KB
testcase_05 AC 172 ms
78,936 KB
testcase_06 AC 141 ms
79,064 KB
testcase_07 AC 197 ms
79,108 KB
testcase_08 AC 181 ms
79,936 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 69 ms
71,404 KB
testcase_12 WA -
testcase_13 AC 131 ms
78,064 KB
testcase_14 AC 135 ms
78,008 KB
testcase_15 AC 134 ms
77,732 KB
testcase_16 AC 148 ms
78,284 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 149 ms
78,536 KB
testcase_20 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

from heapq import heappush, heappop
import sys
input = sys.stdin.readline

def dijkstra(si, sj):
    dist = [[V] * N for _ in range(N)]
    dist[si][sj] = 0
    pq = [(0, 0, 0)]
    while pq:
        d, i, j = heappop(pq)
        for di, dj in [(1, 0), (0, 1), (-1, 0), (0, -1)]:
            ni, nj = i + di, j + dj
            if 0 <= ni < N and 0 <= nj < N and dist[ni][nj] > d + L[ni][nj]:
                dist[ni][nj] = d + L[ni][nj]
                heappush(pq, (d + L[ni][nj], ni, nj))
    return dist


N, V, Ox, Oy = map(int, input().split())
Ox -= 1
Oy -= 1
L = [list(map(int, input().split())) for _ in range(N)]
dist0 = dijkstra(0, 0)
dist1 = dijkstra(N - 1, N - 1)
print('YES' if dist0[N-1][N-1] < V or (V - dist0[Ox][Oy]) * 2 > dist1[Ox][Oy] else 'NO')
0