結果
問題 |
No.1949 足し算するだけのパズルゲーム(2)
|
ユーザー |
![]() |
提出日時 | 2022-05-20 21:35:00 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 904 ms / 3,000 ms |
コード長 | 701 bytes |
コンパイル時間 | 392 ms |
コンパイル使用メモリ | 82,048 KB |
実行使用メモリ | 100,360 KB |
最終ジャッジ日時 | 2024-09-20 07:27:15 |
合計ジャッジ時間 | 7,905 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 26 |
ソースコード
import sys input = sys.stdin.readline import heapq H,W,x,y=map(int,input().split()) A=[list(map(int,input().split())) for i in range(H)] x-=1 y-=1 NOW=A[x][y] USE=[[0]*W for i in range(H)] USE[x][y]=1 Q=[] for z,w in [(x+1,y),(x-1,y),(x,y+1),(x,y-1)]: if 0<=z<H and 0<=w<W: heapq.heappush(Q,(A[z][w],z,w)) USE[z][w]=1 while Q: if Q[0][0]<NOW: p,x,y=heapq.heappop(Q) NOW+=p USE[x][y]=1 for z,w in [(x+1,y),(x-1,y),(x,y+1),(x,y-1)]: if 0<=z<H and 0<=w<W and USE[z][w]==0: heapq.heappush(Q,(A[z][w],z,w)) USE[z][w]=1 else: print("No") exit() print("Yes")