結果
| 問題 | No.1949 足し算するだけのパズルゲーム(2) |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-03-31 08:26:34 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 876 bytes |
| 記録 | |
| コンパイル時間 | 146 ms |
| コンパイル使用メモリ | 85,120 KB |
| 実行使用メモリ | 340,616 KB |
| 最終ジャッジ日時 | 2026-03-31 08:26:55 |
| 合計ジャッジ時間 | 6,301 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 14 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)]
B[y][x] = 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
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]
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
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)