結果
| 問題 | No.1949 足し算するだけのパズルゲーム(2) |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-03-31 08:12:43 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 907 bytes |
| 記録 | |
| コンパイル時間 | 286 ms |
| コンパイル使用メモリ | 85,804 KB |
| 実行使用メモリ | 168,676 KB |
| 最終ジャッジ日時 | 2026-03-31 08:12:50 |
| 合計ジャッジ時間 | 2,840 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 14 WA * 12 |
ソースコード
from collections import deque
H,W,y,x = map(int, input().split())
y -= 1
x -= 1
A = [list(map(int, input().split())) for _ in range(H)]
amax = 0
for i in range(H):
amax = max(amax, max(A[i]))
B = [[0 for _ in range(W)] for _ in range(H)]
B[y][x] = 1
cnt = 1
tot = A[y][x]
que = deque([])
for dy,dx in [(1,0),(-1,0),(0,1),(0,-1)]:
if 0<=y+dy<H and 0<=x+dx<W and B[y+dy][x+dx]==0:
B[y+dy][x+dx] = 1
cnt += 1
que.append((y+dy,x+dx))
ans = "No"
cnt0 = cnt
while que:
i,j = que.popleft()
if tot>A[i][j]:
tot += A[i][j]
for dy,dx in [(1,0),(-1,0),(0,1),(0,-1)]:
if 0<=i+dy<H and 0<=j+dx<W and B[i+dy][j+dx]==0:
B[i+dy][j+dx] = 1
cnt += 1
que.append((i+dy,j+dx))
else:
que.append((i,j))
if tot>amax:
ans = "Yes"
break
if cnt==cnt0:break
cnt0 = cnt
print(ans)