結果
問題 | No.1949 足し算するだけのパズルゲーム(2) |
ユーザー |
![]() |
提出日時 | 2022-12-14 19:48:21 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,140 bytes |
コンパイル時間 | 493 ms |
コンパイル使用メモリ | 12,928 KB |
実行使用メモリ | 31,872 KB |
最終ジャッジ日時 | 2024-11-08 11:23:55 |
合計ジャッジ時間 | 11,028 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 21 WA * 5 |
ソースコード
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[sy][sx] = Truehq = [(a[sy][sx], sy, sx)]heapify(hq)cnt = 1cur_atk = a[sy][sx]a[sy][sx] = 0dx = [1, 0, -1, 0, 1, -1, -1, 1]dy = [0, 1, 0, -1, 1, 1, -1, -1]for i in range(4):ny = sy + dy[i]nx = sx + dx[i]if 0 <= ny < h and 0 <= nx < w:used[ny][nx] = Trueheappush(hq, (a[ny][nx], ny, nx))cnt += 1while hq:atk, y, x = heappop(hq)if cur_atk <= atk:breakcur_atk += atkfor i in range(4):ny = y + dy[i]nx = x + dx[i]if 0 <= ny < h and 0 <= nx < w and not used[ny][nx]:used[ny][nx] = Trueheappush(hq, (a[ny][nx], ny, nx))cnt += 1if cnt == h * w:print("Yes")else:print("No")if __name__ == "__main__":main()"""WIP"""