結果
問題 | No.1949 足し算するだけのパズルゲーム(2) |
ユーザー | norioc |
提出日時 | 2022-05-20 22:47:06 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 1,487 ms / 3,000 ms |
コード長 | 747 bytes |
コンパイル時間 | 370 ms |
コンパイル使用メモリ | 81,632 KB |
実行使用メモリ | 136,664 KB |
最終ジャッジ日時 | 2023-10-20 13:36:52 |
合計ジャッジ時間 | 13,330 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 44 ms
53,492 KB |
testcase_01 | AC | 41 ms
53,492 KB |
testcase_02 | AC | 41 ms
53,492 KB |
testcase_03 | AC | 41 ms
53,492 KB |
testcase_04 | AC | 41 ms
53,492 KB |
testcase_05 | AC | 40 ms
53,492 KB |
testcase_06 | AC | 41 ms
53,492 KB |
testcase_07 | AC | 715 ms
119,208 KB |
testcase_08 | AC | 82 ms
76,228 KB |
testcase_09 | AC | 746 ms
119,220 KB |
testcase_10 | AC | 805 ms
119,820 KB |
testcase_11 | AC | 853 ms
121,588 KB |
testcase_12 | AC | 848 ms
120,028 KB |
testcase_13 | AC | 829 ms
121,004 KB |
testcase_14 | AC | 886 ms
136,660 KB |
testcase_15 | AC | 883 ms
136,664 KB |
testcase_16 | AC | 73 ms
76,684 KB |
testcase_17 | AC | 1,487 ms
134,112 KB |
testcase_18 | AC | 79 ms
76,684 KB |
testcase_19 | AC | 41 ms
53,492 KB |
testcase_20 | AC | 42 ms
53,492 KB |
testcase_21 | AC | 42 ms
53,492 KB |
testcase_22 | AC | 1,098 ms
128,380 KB |
testcase_23 | AC | 41 ms
53,492 KB |
testcase_24 | AC | 470 ms
97,272 KB |
testcase_25 | AC | 735 ms
119,280 KB |
ソースコード
from heapq import heappush, heappop H, W, Y, X = map(int, input().split()) A = [] for _ in range(H): A.append(list(map(int, input().split()))) def delta(row, col): for dr, dc in [(-1, 0), (1, 0), (0, -1), (0, 1)]: r = row + dr c = col + dc if not (0 <= r < H and 0 <= c < W): continue yield r, c row = Y-1 col = X-1 atk = A[row][col] q = [] used = {(row, col)} for r, c in delta(row, col): heappush(q, (A[r][c], r, c)) used.add((r, c)) while q: a, row, col = heappop(q) if a >= atk: print('No') break atk += a for r, c in delta(row, col): if (r, c) in used: continue heappush(q, (A[r][c], r, c)) used.add((r, c)) else: print('Yes')