結果
問題 | No.1949 足し算するだけのパズルゲーム(2) |
ユーザー | とりゐ |
提出日時 | 2022-05-20 22:11:18 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 925 bytes |
コンパイル時間 | 171 ms |
コンパイル使用メモリ | 81,728 KB |
実行使用メモリ | 128,448 KB |
最終ジャッジ日時 | 2023-10-20 12:53:47 |
合計ジャッジ時間 | 21,642 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge14 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 40 ms
53,564 KB |
testcase_01 | AC | 43 ms
53,532 KB |
testcase_02 | AC | 42 ms
53,532 KB |
testcase_03 | AC | 42 ms
53,532 KB |
testcase_04 | AC | 43 ms
53,532 KB |
testcase_05 | AC | 41 ms
53,532 KB |
testcase_06 | AC | 41 ms
53,532 KB |
testcase_07 | AC | 1,816 ms
85,416 KB |
testcase_08 | AC | 86 ms
76,192 KB |
testcase_09 | AC | 1,973 ms
83,856 KB |
testcase_10 | AC | 2,254 ms
84,288 KB |
testcase_11 | AC | 2,380 ms
84,296 KB |
testcase_12 | AC | 2,311 ms
84,484 KB |
testcase_13 | AC | 2,378 ms
84,752 KB |
testcase_14 | AC | 1,388 ms
128,448 KB |
testcase_15 | AC | 1,396 ms
128,420 KB |
testcase_16 | AC | 77 ms
76,656 KB |
testcase_17 | TLE | - |
testcase_18 | -- | - |
testcase_19 | -- | - |
testcase_20 | -- | - |
testcase_21 | -- | - |
testcase_22 | -- | - |
testcase_23 | -- | - |
testcase_24 | -- | - |
testcase_25 | -- | - |
ソースコード
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')