結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 38 ms
53,556 KB
testcase_02 AC 35 ms
53,556 KB
testcase_03 AC 35 ms
53,556 KB
testcase_04 AC 35 ms
53,556 KB
testcase_05 AC 32 ms
53,556 KB
testcase_06 AC 33 ms
53,556 KB
testcase_07 WA -
testcase_08 AC 67 ms
76,412 KB
testcase_09 AC 836 ms
80,420 KB
testcase_10 WA -
testcase_11 AC 979 ms
80,432 KB
testcase_12 AC 1,000 ms
80,488 KB
testcase_13 AC 62 ms
77,820 KB
testcase_14 AC 95 ms
78,068 KB
testcase_15 AC 95 ms
78,072 KB
testcase_16 AC 57 ms
76,896 KB
testcase_17 WA -
testcase_18 AC 62 ms
76,900 KB
testcase_19 AC 36 ms
53,556 KB
testcase_20 AC 37 ms
53,556 KB
testcase_21 AC 37 ms
53,556 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 491 ms
79,108 KB
testcase_25 AC 789 ms
80,888 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
    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 pow>A[ny][nx] and 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