結果

問題 No.1949 足し算するだけのパズルゲーム(2)
ユーザー 👑 H20H20
提出日時 2022-04-03 10:58:45
言語 PyPy3
(7.3.15)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 589 bytes
コンパイル時間 380 ms
コンパイル使用メモリ 87,224 KB
実行使用メモリ 102,864 KB
最終ジャッジ日時 2023-09-09 03:33:30
合計ジャッジ時間 9,145 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 78 ms
71,288 KB
testcase_01 AC 80 ms
71,496 KB
testcase_02 AC 79 ms
71,376 KB
testcase_03 AC 79 ms
71,232 KB
testcase_04 AC 78 ms
71,288 KB
testcase_05 AC 76 ms
71,252 KB
testcase_06 WA -
testcase_07 AC 428 ms
82,460 KB
testcase_08 WA -
testcase_09 AC 486 ms
82,504 KB
testcase_10 WA -
testcase_11 AC 552 ms
83,144 KB
testcase_12 AC 540 ms
83,168 KB
testcase_13 AC 104 ms
77,788 KB
testcase_14 AC 679 ms
102,824 KB
testcase_15 AC 671 ms
102,864 KB
testcase_16 AC 106 ms
77,728 KB
testcase_17 AC 1,050 ms
97,800 KB
testcase_18 AC 106 ms
78,208 KB
testcase_19 AC 79 ms
71,172 KB
testcase_20 WA -
testcase_21 AC 77 ms
71,080 KB
testcase_22 AC 737 ms
91,728 KB
testcase_23 AC 79 ms
71,084 KB
testcase_24 AC 359 ms
82,784 KB
testcase_25 AC 463 ms
82,724 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import heapq

H,W,Y,X = map(int, input().split())
A = []
for _ in range(H):
    A.append(list(map(int, input().split())))
T = [[0]*W for _ in range(H)]
H,W,Y,X=H-1,W-1,Y-1,X-1
heap = []
T[Y][X]=1
V = A[Y][X]
A[Y][X]=0
heapq.heappush(heap,(A[Y][X],Y,X))

HI = [1,0,-1,0]
WI = [0,1,0,-1]
while len(heap):
    v,h,w = heapq.heappop(heap)
    if V<=v:
        print('No')
        exit()
    V+=v
    for i in range(4):
        nh=h+HI[i]
        nw=w+WI[i]
        if 0<=nh<H and 0<=nw<W and T[nh][nw]==0:
            T[nh][nw]=1
            heapq.heappush(heap,(A[nh][nw],nh,nw))
print('Yes')
0