結果
| 問題 |
No.1949 足し算するだけのパズルゲーム(2)
|
| コンテスト | |
| ユーザー |
とりゐ
|
| 提出日時 | 2022-05-20 22:13:24 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 930 ms / 3,000 ms |
| コード長 | 1,008 bytes |
| コンパイル時間 | 144 ms |
| コンパイル使用メモリ | 82,176 KB |
| 実行使用メモリ | 103,292 KB |
| 最終ジャッジ日時 | 2024-09-20 08:24:52 |
| 合計ジャッジ時間 | 8,311 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 26 |
ソースコード
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)])
added=[[False]*w for i in range(h)]
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 and not added[nx][ny]:
hq.append((a[nx][ny],nx,ny))
added[nx][ny]=True
print('Yes')
とりゐ