結果
問題 |
No.1949 足し算するだけのパズルゲーム(2)
|
ユーザー |
![]() |
提出日時 | 2022-05-20 21:27:05 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 692 bytes |
コンパイル時間 | 263 ms |
コンパイル使用メモリ | 82,104 KB |
実行使用メモリ | 101,612 KB |
最終ジャッジ日時 | 2024-09-20 07:16:17 |
合計ジャッジ時間 | 9,517 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 23 WA * 3 |
ソースコード
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] B=0 USE=[[0]*W for i in range(H)] 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")