結果
問題 |
No.1949 足し算するだけのパズルゲーム(2)
|
ユーザー |
![]() |
提出日時 | 2022-05-20 22:11:18 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 925 bytes |
コンパイル時間 | 165 ms |
コンパイル使用メモリ | 82,500 KB |
実行使用メモリ | 128,832 KB |
最終ジャッジ日時 | 2024-09-20 08:22:26 |
合計ジャッジ時間 | 20,623 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 24 TLE * 2 |
ソースコード
h,w,sy,sx=map(int,input().split()) a=[] for _ in range(h): a.append(list(map(int,input().split()))) import heapq class HQ: def __init__(self,a): self.hq=a.copy() heapq.heapify(self.hq) def get(self): if self.hq: return self.hq[0] else: return False def len(self): return len(self.hq) def pop(self): if self.hq: return heapq.heappop(self.hq) else: return False def append(self,i): heapq.heappush(self.hq,i) dxdy=[(0,1),(1,0),(0,-1),(-1,0)] seen=[[False]*w for i in range(h)] now=0 hq=HQ([(a[sy-1][sx-1],sy-1,sx-1)]) while hq.len()>0: c,x,y=hq.pop() #print(c,x,y,now) if seen[x][y]:continue seen[x][y]=True if x==sy-1 and y==sx-1: now+=c else: if now>c: now+=c else: print('No') exit() for dx,dy in dxdy: nx,ny=x+dx,y+dy if 0<=nx<h and 0<=ny<w: hq.append((a[nx][ny],nx,ny)) print('Yes')