結果

問題 No.1949 足し算するだけのパズルゲーム(2)
ユーザー ikomaikoma
提出日時 2022-05-21 00:19:52
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 664 bytes
コンパイル時間 260 ms
コンパイル使用メモリ 81,808 KB
実行使用メモリ 125,348 KB
最終ジャッジ日時 2023-10-20 15:12:14
合計ジャッジ時間 21,481 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
53,560 KB
testcase_01 WA -
testcase_02 AC 37 ms
53,560 KB
testcase_03 AC 35 ms
53,560 KB
testcase_04 WA -
testcase_05 AC 33 ms
53,560 KB
testcase_06 WA -
testcase_07 AC 663 ms
80,640 KB
testcase_08 WA -
testcase_09 AC 844 ms
80,368 KB
testcase_10 AC 927 ms
80,712 KB
testcase_11 AC 1,015 ms
80,828 KB
testcase_12 AC 994 ms
81,104 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 2,046 ms
125,348 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 37 ms
53,560 KB
testcase_21 WA -
testcase_22 AC 1,439 ms
110,880 KB
testcase_23 AC 34 ms
53,560 KB
testcase_24 WA -
testcase_25 AC 798 ms
81,028 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)]
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