結果
問題 | No.1949 足し算するだけのパズルゲーム(2) |
ユーザー |
![]() |
提出日時 | 2022-12-13 23:17:14 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,005 bytes |
コンパイル時間 | 131 ms |
コンパイル使用メモリ | 12,800 KB |
実行使用メモリ | 31,872 KB |
最終ジャッジ日時 | 2024-11-07 16:52:46 |
合計ジャッジ時間 | 10,718 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 17 WA * 8 RE * 1 |
ソースコード
from heapq import heapify, heappop, heappushdef main():h, w, sy, sx = map(int, input().split())sy -= 1sx -= 1a = [list(map(int, input().split())) for _ in range(h)]used = [[False] * w for _ in range(h)]used[sx][sy] = Truehq = [(a[sx][sy], sx, sy)]heapify(hq)cur_atk = a[sx][sy]dx = [1, 0, -1, 0, 1, -1, -1, 1]dy = [0, 1, 0, -1, 1, 1, -1, -1]for i in range(4):x = sx + dx[i]y = sy + dy[i]if 0 <= x < h and 0 <= y < w:used[x][y] = Trueheappush(hq, (a[x][y], x, y))while hq:atk, x, y = heappop(hq)if cur_atk <= a[x][y]:exit(print("No"))cur_atk += a[x][y]for i in range(4):nx = x + dx[i]ny = y + dy[i]if 0 <= nx < h and 0 <= ny < w and not used[nx][ny]:used[nx][ny] = Trueheappush(hq, (a[nx][ny], nx, ny))print("Yes")if __name__ == "__main__":main()