結果

問題 No.1949 足し算するだけのパズルゲーム(2)
ユーザー ikomaikoma
提出日時 2022-05-21 00:22:14
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 2,358 ms / 3,000 ms
コード長 695 bytes
コンパイル時間 1,060 ms
コンパイル使用メモリ 81,844 KB
実行使用メモリ 124,376 KB
最終ジャッジ日時 2023-10-20 15:12:51
合計ジャッジ時間 15,224 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 40 ms
53,468 KB
testcase_01 AC 38 ms
53,468 KB
testcase_02 AC 39 ms
53,468 KB
testcase_03 AC 39 ms
53,468 KB
testcase_04 AC 39 ms
53,468 KB
testcase_05 AC 39 ms
53,468 KB
testcase_06 AC 39 ms
53,468 KB
testcase_07 AC 742 ms
80,628 KB
testcase_08 AC 76 ms
76,336 KB
testcase_09 AC 927 ms
80,252 KB
testcase_10 AC 1,034 ms
80,620 KB
testcase_11 AC 1,114 ms
80,672 KB
testcase_12 AC 1,106 ms
80,780 KB
testcase_13 AC 1,148 ms
81,148 KB
testcase_14 AC 740 ms
118,024 KB
testcase_15 AC 735 ms
118,028 KB
testcase_16 AC 64 ms
76,804 KB
testcase_17 AC 2,358 ms
124,376 KB
testcase_18 AC 67 ms
76,808 KB
testcase_19 AC 38 ms
53,472 KB
testcase_20 AC 40 ms
53,472 KB
testcase_21 AC 40 ms
53,472 KB
testcase_22 AC 1,641 ms
110,976 KB
testcase_23 AC 38 ms
53,472 KB
testcase_24 AC 607 ms
79,344 KB
testcase_25 AC 888 ms
80,804 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline
from heapq import heappush,heappop,heapify,heappushpop,heapreplace,merge,nlargest,nsmallest


H,W,Y,X=map(int,input().split())
A=[list(map(int,input().split())) for _ in range(H)]
INF=float("inf")
pow = 0

que = [(A[Y-1][X-1],Y-1,X-1)]
pow=A[Y-1][X-1]+1
A[Y-1][X-1]=-1
while que:
    a,y,x=heappop(que)
    if A[y][x]==0:continue
    if A[y][x]>=pow:break
    pow+=A[y][x]
    A[y][x]=0
    for ny,nx in [(y-1,x),(y+1,x),(y,x-1),(y,x+1)]:
        if 0<=ny<H and 0<=nx<W:
            if A[ny][nx]>0:
                heappush(que,(A[ny][nx],ny,nx))

for y in range(H):
    if any([a!=0 for a in A[y]]):
        print("No")
        break
else:
    print("Yes")
0