結果
| 問題 |
No.1949 足し算するだけのパズルゲーム(2)
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-06-25 02:59:06 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 830 bytes |
| コンパイル時間 | 350 ms |
| コンパイル使用メモリ | 82,424 KB |
| 実行使用メモリ | 103,184 KB |
| 最終ジャッジ日時 | 2024-11-08 22:29:28 |
| 合計ジャッジ時間 | 11,278 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 17 WA * 8 RE * 1 |
ソースコード
import sys
from heapq import heapify, heappush, heappop
input = lambda: sys.stdin.readline().rstrip()\
dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [1, 0, -1, 1, -1, 1, 0, -1]
# ----------------------- #
h, w, x, y = map(int, input().split())
x -= 1
y -= 1
A = [list(map(int, input().split())) for _ in range(h)]
hq = [(0, y, x)]
now = A[y][x]
seen = [[False]*w for _ in range(h)]
seen[y][x] = True
def is_infield(y, x):
return 0 <= y < h and 0 <= x < w
killed = 0
while hq:
a, vy, vx = heappop(hq)
if now <= a:
print('No')
exit()
killed += 1
now += a
for i in range(len(dx)):
ny, nx = vy+dy[i], vx+dx[i]
if not is_infield(ny, nx):
continue
if seen[ny][nx]:
continue
seen[ny][nx] = True
heappush(hq, (A[ny][nx], ny, nx))
if killed == h*w:
print('Yes')
else:
print('No')