結果

問題 No.1949 足し算するだけのパズルゲーム(2)
ユーザー rlangevinrlangevin
提出日時 2023-01-21 18:00:43
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 653 bytes
コンパイル時間 428 ms
コンパイル使用メモリ 87,140 KB
実行使用メモリ 116,360 KB
最終ジャッジ日時 2023-09-06 06:24:54
合計ジャッジ時間 9,406 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
71,104 KB
testcase_01 AC 74 ms
71,104 KB
testcase_02 AC 73 ms
71,248 KB
testcase_03 AC 75 ms
71,316 KB
testcase_04 AC 82 ms
71,112 KB
testcase_05 AC 78 ms
71,240 KB
testcase_06 AC 77 ms
71,244 KB
testcase_07 WA -
testcase_08 AC 115 ms
78,280 KB
testcase_09 AC 598 ms
114,724 KB
testcase_10 WA -
testcase_11 AC 606 ms
114,376 KB
testcase_12 AC 631 ms
115,452 KB
testcase_13 AC 110 ms
78,740 KB
testcase_14 AC 208 ms
91,824 KB
testcase_15 AC 205 ms
91,728 KB
testcase_16 AC 104 ms
77,640 KB
testcase_17 AC 591 ms
115,672 KB
testcase_18 AC 105 ms
78,056 KB
testcase_19 AC 78 ms
70,984 KB
testcase_20 AC 75 ms
71,412 KB
testcase_21 AC 76 ms
71,256 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 336 ms
93,444 KB
testcase_25 AC 601 ms
114,852 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from heapq import *

H, W, X, Y = map(int, input().split())
A = []
for i in range(H):
    A.append(list(map(int, input().split())))
    
S = set()
X, Y = X - 1, Y - 1
S.add((X, Y))
Q = [(A[X][Y], X, Y)]
dx = [1, 0, -1, 0]
dy = [0, 1, 0, -1]
now = A[X][Y]
while Q:
    v, px, py = heappop(Q)
    for k in range(4):
        x = px + dx[k]
        y = py + dy[k]
        if x < 0 or x > H - 1 or y < 0 or y > W - 1:
            continue
        if (x, y) in S:
            continue
        if now <= A[x][y]:
            continue
        S.add((x, y))
        now += A[x][y]
        heappush(Q, (now, x, y))
print("Yes") if len(S) == H * W else print("No")
0