結果
問題 | No.20 砂漠のオアシス |
ユーザー | sotanishy |
提出日時 | 2021-03-16 22:31:14 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 844 bytes |
コンパイル時間 | 332 ms |
コンパイル使用メモリ | 87,300 KB |
実行使用メモリ | 79,796 KB |
最終ジャッジ日時 | 2023-08-08 12:23:21 |
合計ジャッジ時間 | 5,665 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 68 ms
71,460 KB |
testcase_01 | AC | 67 ms
71,524 KB |
testcase_02 | AC | 70 ms
71,332 KB |
testcase_03 | AC | 114 ms
77,720 KB |
testcase_04 | AC | 138 ms
78,580 KB |
testcase_05 | AC | 183 ms
79,208 KB |
testcase_06 | AC | 166 ms
78,936 KB |
testcase_07 | AC | 230 ms
79,080 KB |
testcase_08 | AC | 200 ms
79,796 KB |
testcase_09 | AC | 206 ms
79,596 KB |
testcase_10 | WA | - |
testcase_11 | AC | 78 ms
71,572 KB |
testcase_12 | WA | - |
testcase_13 | AC | 149 ms
78,712 KB |
testcase_14 | AC | 146 ms
78,736 KB |
testcase_15 | AC | 144 ms
78,540 KB |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | AC | 146 ms
78,648 KB |
testcase_20 | AC | 109 ms
77,572 KB |
ソースコード
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, si, sj)] 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) if Ox == Oy == -1: print('YES' if dist0[N-1][N-1] < V else 'NO') exit() dist1 = dijkstra(Ox, Oy) print('YES' if dist0[N-1][N-1] < V or (V - dist0[Ox][Oy]) * 2 > dist1[N-1][N-1] else 'NO')