結果
問題 |
No.1949 足し算するだけのパズルゲーム(2)
|
ユーザー |
![]() |
提出日時 | 2022-04-10 19:31:58 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 758 bytes |
コンパイル時間 | 204 ms |
コンパイル使用メモリ | 82,420 KB |
実行使用メモリ | 101,448 KB |
最終ジャッジ日時 | 2024-06-26 20:42:41 |
合計ジャッジ時間 | 7,676 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 22 WA * 4 |
ソースコード
import heapq H,W,Y,X = map(int, input().split()) A = [] for _ in range(H): A.append(list(map(int, input().split()))) if not(1<=H<=500 and 1<=W<=500 and len(A)==H and 1<=Y<=H and 1<=X<=W): exit() for a in A: if not (len(a)==W and 1<=min(a) and max(a)<=10**9): exit() T = [[0]*W for _ in range(H)] H,W,Y,X=H-1,W-1,Y-1,X-1 heap = [] T[Y][X]=1 V = A[Y][X] A[Y][X]=0 heapq.heappush(heap,(A[Y][X],Y,X)) HI = [1,0,-1,0] WI = [0,1,0,-1] while len(heap): v,h,w = heapq.heappop(heap) if V<=v: print('No') exit() V+=v for i in range(4): nh=h+HI[i] nw=w+WI[i] if 0<=nh<H and 0<=nw<W and T[nh][nw]==0: T[nh][nw]=1 heapq.heappush(heap,(A[nh][nw],nh,nw)) print('Yes')