結果
| 問題 | No.1949 足し算するだけのパズルゲーム(2) |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-03-31 08:39:35 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 854 bytes |
| 記録 | |
| コンパイル時間 | 203 ms |
| コンパイル使用メモリ | 85,376 KB |
| 実行使用メモリ | 89,216 KB |
| 最終ジャッジ日時 | 2026-03-31 08:40:51 |
| 合計ジャッジ時間 | 6,635 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge1_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 13 WA * 1 TLE * 1 -- * 11 |
ソースコード
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)]
tot = A[y][x]
que = deque([])
B[y][x] = 1
for dy,dx in [(1,0),(-1,0),(0,1),(0,-1)]:
if 0<=y+dy<H and 0<=x+dx<W:
que.append((y+dy,x+dx))
ans = "No"
cnt = 0
while que:
i,j = que.popleft()
if tot>A[i][j]:
cnt = 0
tot += A[i][j]
if B[i][j]==0:
B[i][j] = 1
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:
que.append((i+dy,j+dx))
else:
que.append((i,j))
cnt += 1
if tot>amax:
ans = "Yes"
break
if cnt==len(que):break
print(ans)