結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
53,424 KB
testcase_01 AC 38 ms
53,424 KB
testcase_02 AC 43 ms
53,424 KB
testcase_03 AC 40 ms
53,424 KB
testcase_04 AC 40 ms
53,424 KB
testcase_05 AC 39 ms
53,424 KB
testcase_06 AC 39 ms
53,424 KB
testcase_07 AC 407 ms
80,728 KB
testcase_08 AC 77 ms
76,276 KB
testcase_09 AC 461 ms
81,004 KB
testcase_10 AC 495 ms
81,572 KB
testcase_11 AC 521 ms
81,496 KB
testcase_12 AC 513 ms
81,520 KB
testcase_13 AC 518 ms
81,344 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 66 ms
76,744 KB
testcase_17 AC 1,008 ms
95,976 KB
testcase_18 AC 66 ms
76,748 KB
testcase_19 WA -
testcase_20 AC 41 ms
53,424 KB
testcase_21 AC 41 ms
53,424 KB
testcase_22 AC 720 ms
90,016 KB
testcase_23 AC 39 ms
53,424 KB
testcase_24 AC 305 ms
80,520 KB
testcase_25 AC 452 ms
81,428 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)]

USE[0][0]=1

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