結果
| 問題 |
No.1949 足し算するだけのパズルゲーム(2)
|
| コンテスト | |
| ユーザー |
hiragn
|
| 提出日時 | 2022-12-14 20:11:32 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
AC
|
| 実行時間 | 800 ms / 3,000 ms |
| コード長 | 908 bytes |
| コンパイル時間 | 359 ms |
| コンパイル使用メモリ | 12,672 KB |
| 実行使用メモリ | 31,744 KB |
| 最終ジャッジ日時 | 2024-11-08 11:49:28 |
| 合計ジャッジ時間 | 9,459 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 26 |
ソースコード
from heapq import heapify, heappop, heappush
def main():
h, w, sy, sx = map(int, input().split())
sy -= 1
sx -= 1
a = [list(map(int, input().split())) for _ in range(h)]
used = [[False] * w for _ in range(h)]
used[sy][sx] = True
hq = [(a[sy][sx], sy, sx)]
heapify(hq)
cnt = 0
cur_atk = 0
a[sy][sx] = 0
dx = [1, 0, -1, 0, 1, -1, -1, 1]
dy = [0, 1, 0, -1, 1, 1, -1, -1]
while hq:
atk, y, x = heappop(hq)
if cnt > 0 and cur_atk <= atk:
exit(print("No"))
cnt += 1
cur_atk += atk
for 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] = True
heappush(hq, (a[ny][nx], ny, nx))
print("Yes")
if __name__ == "__main__":
main()
"""
while のはじめに cnt>0
"""
hiragn