結果
問題 | No.20 砂漠のオアシス |
ユーザー | terrafarm |
提出日時 | 2021-02-14 16:33:13 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,330 bytes |
コンパイル時間 | 310 ms |
コンパイル使用メモリ | 86,944 KB |
実行使用メモリ | 100,344 KB |
最終ジャッジ日時 | 2023-09-29 07:16:29 |
合計ジャッジ時間 | 9,453 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 282 ms
92,832 KB |
testcase_01 | AC | 276 ms
92,784 KB |
testcase_02 | AC | 278 ms
92,860 KB |
testcase_03 | AC | 318 ms
96,112 KB |
testcase_04 | AC | 345 ms
95,928 KB |
testcase_05 | AC | 524 ms
100,344 KB |
testcase_06 | AC | 458 ms
97,656 KB |
testcase_07 | AC | 454 ms
97,744 KB |
testcase_08 | AC | 454 ms
97,460 KB |
testcase_09 | AC | 449 ms
98,120 KB |
testcase_10 | WA | - |
testcase_11 | AC | 269 ms
92,744 KB |
testcase_12 | WA | - |
testcase_13 | AC | 327 ms
95,748 KB |
testcase_14 | AC | 343 ms
96,124 KB |
testcase_15 | AC | 335 ms
95,812 KB |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | AC | 348 ms
95,684 KB |
testcase_20 | AC | 320 ms
95,804 KB |
ソースコード
import heapq import logging import sys from inspect import currentframe sys.setrecursionlimit(10 ** 6) input = sys.stdin.readline logging.basicConfig(level=logging.DEBUG) def dbg(*args): id2names = {id(v): k for k, v in currentframe().f_back.f_locals.items()} logging.debug(", ".join(id2names.get(id(arg), "???") + " = " + repr(arg) for arg in args)) def dijkstra_grid(sx, sy, grid): d = [[float('inf')] * n for _ in range(n)] d[sx][sy] = 0 pq = [(0, sx, sy)] while pq: c, x, y = heapq.heappop(pq) if d[x][y] < c: continue for dx, dy in ((-1, 0), (1, 0), (0, 1), (0, -1)): nx, ny = x + dx, y + dy if 0 <= nx < n and 0 <= ny < n and c + grid[nx][ny] < d[nx][ny]: d[nx][ny] = c + grid[nx][ny] heapq.heappush(pq, (d[nx][ny], nx, ny)) return d n, v, ox, oy = map(int, input().split()) l = [list(map(int, input().split())) for _ in range(n)] d1 = dijkstra_grid(0, 0, l) if ox == 0 and oy == 0: if d1[n - 1][n - 1] < v: print("YES") else: print("NO") else: ox -= 1 oy -= 1 d2 = dijkstra_grid(ox, oy, l) if d1[n - 1][n - 1] < v: print("YES") elif d1[ox][oy] < v and d2[n - 1][n - 1] < 2 * (v - d1[ox][oy]): print("YES") else: print("NO")