結果
| 問題 |
No.1949 足し算するだけのパズルゲーム(2)
|
| コンテスト | |
| ユーザー |
norioc
|
| 提出日時 | 2022-05-20 22:40:22 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 767 bytes |
| コンパイル時間 | 155 ms |
| コンパイル使用メモリ | 82,548 KB |
| 実行使用メモリ | 137,104 KB |
| 最終ジャッジ日時 | 2024-09-20 08:59:48 |
| 合計ジャッジ時間 | 11,164 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 24 WA * 2 |
ソースコード
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:
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))
if len(used) == H * W:
print('Yes')
else:
print('No')
norioc