結果
| 問題 |
No.1949 足し算するだけのパズルゲーム(2)
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-05-20 23:16:22 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 775 bytes |
| コンパイル時間 | 128 ms |
| コンパイル使用メモリ | 82,116 KB |
| 実行使用メモリ | 306,692 KB |
| 最終ジャッジ日時 | 2024-09-20 09:40:28 |
| 合計ジャッジ時間 | 5,282 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 7 TLE * 1 -- * 18 |
ソースコード
import sys
input = sys.stdin.readline
from collections import *
from heapq import *
H, W, X, Y = map(int, input().split())
X -= 1
Y -= 1
A = [list(map(int, input().split())) for _ in range(H)]
beat = [[False]*W for _ in range(H)]
beat[X][Y] = True
pq = []
for nx, ny in [(X-1, Y), (X+1, Y), (X, Y-1), (X, Y+1)]:
if 0<=nx<H and 0<=ny<W:
heappush(pq, (A[nx][ny], nx*1000+ny))
now = A[X][Y]
while pq:
if pq[0][0]<now:
a, xy = heappop(pq)
x, y = divmod(xy, 1000)
now += a
beat[x][y] = True
for nx, ny in [(x-1, y), (x+1, y), (x, y-1), (x, y+1)]:
if 0<=nx<H and 0<=ny<W and not beat[nx][ny]:
heappush(pq, (A[nx][ny], nx*1000+ny))
else:
exit(print('No'))
print('Yes')