結果
問題 | No.1949 足し算するだけのパズルゲーム(2) |
ユーザー |
![]() |
提出日時 | 2022-05-21 00:22:14 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 2,034 ms / 3,000 ms |
コード長 | 695 bytes |
コンパイル時間 | 157 ms |
コンパイル使用メモリ | 81,920 KB |
実行使用メモリ | 124,540 KB |
最終ジャッジ日時 | 2024-09-20 10:42:59 |
合計ジャッジ時間 | 13,566 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 26 |
ソースコード
import sys input = sys.stdin.readline from heapq import heappush,heappop,heapify,heappushpop,heapreplace,merge,nlargest,nsmallest H,W,Y,X=map(int,input().split()) A=[list(map(int,input().split())) for _ in range(H)] INF=float("inf") pow = 0 que = [(A[Y-1][X-1],Y-1,X-1)] pow=A[Y-1][X-1]+1 A[Y-1][X-1]=-1 while que: a,y,x=heappop(que) if A[y][x]==0:continue if A[y][x]>=pow:break pow+=A[y][x] A[y][x]=0 for ny,nx in [(y-1,x),(y+1,x),(y,x-1),(y,x+1)]: if 0<=ny<H and 0<=nx<W: if A[ny][nx]>0: heappush(que,(A[ny][nx],ny,nx)) for y in range(H): if any([a!=0 for a in A[y]]): print("No") break else: print("Yes")