結果
問題 |
No.1949 足し算するだけのパズルゲーム(2)
|
ユーザー |
![]() |
提出日時 | 2023-01-21 18:00:43 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 653 bytes |
コンパイル時間 | 169 ms |
コンパイル使用メモリ | 82,404 KB |
実行使用メモリ | 115,768 KB |
最終ジャッジ日時 | 2024-06-24 01:04:35 |
合計ジャッジ時間 | 7,572 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 22 WA * 4 |
ソースコード
from heapq import * H, W, X, Y = map(int, input().split()) A = [] for i in range(H): A.append(list(map(int, input().split()))) S = set() X, Y = X - 1, Y - 1 S.add((X, Y)) Q = [(A[X][Y], X, Y)] dx = [1, 0, -1, 0] dy = [0, 1, 0, -1] now = A[X][Y] while Q: v, px, py = heappop(Q) for k in range(4): x = px + dx[k] y = py + dy[k] if x < 0 or x > H - 1 or y < 0 or y > W - 1: continue if (x, y) in S: continue if now <= A[x][y]: continue S.add((x, y)) now += A[x][y] heappush(Q, (now, x, y)) print("Yes") if len(S) == H * W else print("No")