結果
問題 |
No.1949 足し算するだけのパズルゲーム(2)
|
ユーザー |
|
提出日時 | 2022-05-20 21:59:13 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 865 bytes |
コンパイル時間 | 294 ms |
コンパイル使用メモリ | 82,688 KB |
実行使用メモリ | 99,468 KB |
最終ジャッジ日時 | 2024-09-20 08:06:05 |
合計ジャッジ時間 | 8,810 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 24 WA * 2 |
ソースコード
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)] hq = [] directions = [(-1, 0), (1, 0), (0, -1), (0, 1)] tot = A[x][y] used = [[False] * w for _ in range(h)] used[x][y] = True for dx, dy in directions: nx = x + dx ny = y + dy if nx == -1 or nx == h or ny == -1 or ny == w: continue heappush(hq, (A[nx][ny], nx, ny)) used[nx][ny] = True while hq: a, x, y = heappop(hq) if a >= tot: break tot += a for dx, dy in directions: nx = x + dx ny = y + dy if nx == -1 or nx == h or ny == -1 or ny == w: continue if used[nx][ny]: continue heappush(hq, (A[nx][ny], nx, ny)) used[nx][ny] = True if tot > A[-1][-1] and used[-1][-1]: print("Yes") else: print("No")