結果

問題 No.1949 足し算するだけのパズルゲーム(2)
ユーザー ああいいああいい
提出日時 2022-05-20 22:39:05
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,048 ms / 3,000 ms
コード長 745 bytes
コンパイル時間 249 ms
コンパイル使用メモリ 81,660 KB
実行使用メモリ 99,192 KB
最終ジャッジ日時 2023-10-20 13:26:06
合計ジャッジ時間 9,105 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
53,460 KB
testcase_01 AC 41 ms
53,460 KB
testcase_02 AC 38 ms
53,460 KB
testcase_03 AC 39 ms
53,460 KB
testcase_04 AC 40 ms
53,460 KB
testcase_05 AC 41 ms
53,460 KB
testcase_06 AC 39 ms
53,460 KB
testcase_07 AC 416 ms
80,548 KB
testcase_08 AC 80 ms
76,180 KB
testcase_09 AC 453 ms
80,668 KB
testcase_10 AC 507 ms
80,904 KB
testcase_11 AC 532 ms
81,008 KB
testcase_12 AC 513 ms
81,228 KB
testcase_13 AC 522 ms
81,268 KB
testcase_14 AC 670 ms
99,184 KB
testcase_15 AC 680 ms
99,192 KB
testcase_16 AC 78 ms
76,628 KB
testcase_17 AC 1,048 ms
95,944 KB
testcase_18 AC 69 ms
76,636 KB
testcase_19 AC 39 ms
53,460 KB
testcase_20 AC 42 ms
53,460 KB
testcase_21 AC 41 ms
53,460 KB
testcase_22 AC 749 ms
89,768 KB
testcase_23 AC 39 ms
53,460 KB
testcase_24 AC 335 ms
80,852 KB
testcase_25 AC 456 ms
80,984 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

H,W,Y,X = map(int,input().split())
A = [list(map(int,input().split())) for _ in range(H)]

import heapq

now = A[Y - 1][X - 1]
memo = [[0] * W for _ in range(H)]
memo[Y - 1][X - 1] = 1
count = 1
q = []
l = [(-1,0),(1,0),(0,1),(0,-1)]
X -= 1
Y -= 1
for i,j in l:
    if 0 <= Y + i < H and 0 <= X + j < W:
        heapq.heappush(q,(A[Y + i][X + j],Y + i,X + j))
        memo[Y + i][X + j] = 1
import sys
while q:
    a,y,x = heapq.heappop(q)
    if a >= now:
        print('No')
        exit()
    now += a
    #memo[y][x] = 1
    for i,j in l:
        if 0 <= y + i < H and 0 <= x + j < W:
            if memo[y + i][x + j] == 0:
                memo[y + i][x + j] = 1
                heapq.heappush(q,(A[y + i][x + j],y + i,x + j))
print('Yes')
0