結果
問題 | No.20 砂漠のオアシス |
ユーザー | sotanishy |
提出日時 | 2021-03-16 22:29:43 |
言語 | PyPy3 (7.3.13) |
結果 |
WA
|
実行時間 | - |
コード長 | 842 bytes |
コンパイル時間 | 1,570 ms |
コンパイル使用メモリ | 86,992 KB |
実行使用メモリ | 79,812 KB |
最終ジャッジ日時 | 2023-08-08 12:19:33 |
合計ジャッジ時間 | 4,553 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge14 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 76 ms
71,320 KB |
testcase_01 | AC | 77 ms
71,188 KB |
testcase_02 | AC | 82 ms
71,332 KB |
testcase_03 | AC | 124 ms
77,560 KB |
testcase_04 | AC | 149 ms
78,420 KB |
testcase_05 | AC | 182 ms
79,228 KB |
testcase_06 | AC | 152 ms
78,932 KB |
testcase_07 | AC | 210 ms
79,028 KB |
testcase_08 | AC | 191 ms
79,812 KB |
testcase_09 | AC | 187 ms
79,080 KB |
testcase_10 | WA | - |
testcase_11 | AC | 81 ms
71,300 KB |
testcase_12 | WA | - |
testcase_13 | AC | 144 ms
78,144 KB |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | AC | 149 ms
78,112 KB |
testcase_18 | WA | - |
testcase_19 | AC | 158 ms
78,700 KB |
testcase_20 | WA | - |
ソースコード
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) 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')