結果
| 問題 |
No.1949 足し算するだけのパズルゲーム(2)
|
| コンテスト | |
| ユーザー |
tktk_snsn
|
| 提出日時 | 2022-05-20 22:19:58 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 881 bytes |
| コンパイル時間 | 236 ms |
| コンパイル使用メモリ | 82,172 KB |
| 実行使用メモリ | 52,864 KB |
| 最終ジャッジ日時 | 2024-09-20 08:32:44 |
| 合計ジャッジ時間 | 5,299 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 7 TLE * 1 -- * 18 |
ソースコード
import heapq
import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 15
dydx4 = ((0, 1), (1, 0), (-1, 0), (0, -1))
dydx8 = ((0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1), (-1, 0), (-1, 1))
H, W, X, Y = map(int, input().split())
X -= 1
Y -= 1
A = list(list(map(int, input().split())) for _ in range(H))
def is_inside(x, y):
return 0 <= x < H and 0 <= y < W
tot = A[X][Y]
A[X][Y] = -1
que = []
for dx, dy in dydx4:
nx = X + dx
ny = Y + dy
if is_inside(nx, ny):
heapq.heappush(que, (A[nx][ny], nx, ny))
while que:
a, xi, yi = heapq.heappop(que)
if a >= tot:
print("No")
exit()
tot += a
A[xi][yi] = -1
for dx, dy in dydx4:
nx = xi + dx
ny = yi + dy
if is_inside(nx, ny) and A[nx][ny] != -1:
heapq.heappush(que, (A[nx][ny], nx, ny))
print("Yes")
tktk_snsn