結果

問題 No.1949 足し算するだけのパズルゲーム(2)
ユーザー titiatitia
提出日時 2022-05-20 21:27:05
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 692 bytes
コンパイル時間 155 ms
コンパイル使用メモリ 81,708 KB
実行使用メモリ 100,920 KB
最終ジャッジ日時 2023-10-20 11:44:06
合計ジャッジ時間 10,964 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 43 ms
53,408 KB
testcase_01 AC 42 ms
53,408 KB
testcase_02 AC 38 ms
53,408 KB
testcase_03 AC 39 ms
53,408 KB
testcase_04 AC 38 ms
53,408 KB
testcase_05 AC 38 ms
53,408 KB
testcase_06 AC 40 ms
53,408 KB
testcase_07 AC 408 ms
80,700 KB
testcase_08 AC 74 ms
76,272 KB
testcase_09 AC 457 ms
80,980 KB
testcase_10 AC 497 ms
81,252 KB
testcase_11 AC 517 ms
81,448 KB
testcase_12 AC 518 ms
81,448 KB
testcase_13 AC 522 ms
81,332 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 65 ms
76,732 KB
testcase_17 AC 1,051 ms
95,952 KB
testcase_18 AC 65 ms
76,732 KB
testcase_19 WA -
testcase_20 AC 39 ms
53,408 KB
testcase_21 AC 39 ms
53,408 KB
testcase_22 AC 735 ms
90,024 KB
testcase_23 AC 39 ms
53,408 KB
testcase_24 AC 305 ms
80,492 KB
testcase_25 AC 453 ms
81,396 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline
import heapq

H,W,x,y=map(int,input().split())
A=[list(map(int,input().split())) for i in range(H)]

x-=1
y-=1
NOW=A[x][y]

B=0
USE=[[0]*W for i in range(H)]

Q=[]

for z,w in [(x+1,y),(x-1,y),(x,y+1),(x,y-1)]:
    if 0<=z<H and 0<=w<W:
        heapq.heappush(Q,(A[z][w],z,w))
        USE[z][w]=1

while Q:
    if Q[0][0]<NOW:
        p,x,y=heapq.heappop(Q)
        NOW+=p
        USE[x][y]=1

        for z,w in [(x+1,y),(x-1,y),(x,y+1),(x,y-1)]:
            if 0<=z<H and 0<=w<W and USE[z][w]==0:
                heapq.heappush(Q,(A[z][w],z,w))
                USE[z][w]=1

    else:
        print("No")
        exit()

print("Yes")
        
    
    
0