結果
問題 | No.1949 足し算するだけのパズルゲーム(2) |
ユーザー | tktk_snsn |
提出日時 | 2022-05-20 22:19:58 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 881 bytes |
コンパイル時間 | 180 ms |
コンパイル使用メモリ | 81,772 KB |
実行使用メモリ | 53,512 KB |
最終ジャッジ日時 | 2023-10-20 13:03:58 |
合計ジャッジ時間 | 5,477 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 41 ms
53,512 KB |
testcase_01 | AC | 42 ms
53,484 KB |
testcase_02 | AC | 39 ms
53,484 KB |
testcase_03 | AC | 42 ms
53,484 KB |
testcase_04 | AC | 39 ms
53,484 KB |
testcase_05 | AC | 39 ms
53,484 KB |
testcase_06 | AC | 38 ms
53,484 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 | -- | - |
testcase_21 | -- | - |
testcase_22 | -- | - |
testcase_23 | -- | - |
testcase_24 | -- | - |
testcase_25 | -- | - |
ソースコード
import heapq import sys input = sys.stdin.buffer.readline sys.setrecursionlimit(10 ** 7) inf = 10 ** 15 dydx4 = ((0, 1), (1, 0), (-1, 0), (0, -1)) dydx8 = ((0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1), (-1, 0), (-1, 1)) H, W, X, Y = map(int, input().split()) X -= 1 Y -= 1 A = list(list(map(int, input().split())) for _ in range(H)) def is_inside(x, y): return 0 <= x < H and 0 <= y < W tot = A[X][Y] A[X][Y] = -1 que = [] for dx, dy in dydx4: nx = X + dx ny = Y + dy if is_inside(nx, ny): heapq.heappush(que, (A[nx][ny], nx, ny)) while que: a, xi, yi = heapq.heappop(que) if a >= tot: print("No") exit() tot += a A[xi][yi] = -1 for dx, dy in dydx4: nx = xi + dx ny = yi + dy if is_inside(nx, ny) and A[nx][ny] != -1: heapq.heappush(que, (A[nx][ny], nx, ny)) print("Yes")