結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 36 ms
53,560 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 38 ms
53,560 KB
testcase_05 WA -
testcase_06 AC 33 ms
53,560 KB
testcase_07 WA -
testcase_08 AC 67 ms
76,420 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 54 ms
76,960 KB
testcase_14 AC 60 ms
76,636 KB
testcase_15 AC 63 ms
76,640 KB
testcase_16 AC 63 ms
76,900 KB
testcase_17 WA -
testcase_18 AC 61 ms
76,904 KB
testcase_19 AC 35 ms
53,560 KB
testcase_20 WA -
testcase_21 AC 34 ms
53,560 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 55 ms
76,932 KB
testcase_25 WA -
権限があれば一括ダウンロードができます

ソースコード

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