結果

問題 No.1949 足し算するだけのパズルゲーム(2)
ユーザー nohakai3nohakai3
提出日時 2022-07-30 11:37:16
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 1,414 ms / 3,000 ms
コード長 528 bytes
コンパイル時間 278 ms
コンパイル使用メモリ 10,880 KB
実行使用メモリ 28,952 KB
最終ジャッジ日時 2023-09-27 13:51:57
合計ジャッジ時間 16,706 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 17 ms
8,172 KB
testcase_01 AC 16 ms
8,208 KB
testcase_02 AC 17 ms
8,288 KB
testcase_03 AC 17 ms
8,284 KB
testcase_04 AC 17 ms
8,292 KB
testcase_05 AC 16 ms
8,272 KB
testcase_06 AC 16 ms
8,304 KB
testcase_07 AC 1,164 ms
19,236 KB
testcase_08 AC 89 ms
20,456 KB
testcase_09 AC 1,141 ms
20,376 KB
testcase_10 AC 1,139 ms
20,336 KB
testcase_11 AC 1,177 ms
20,324 KB
testcase_12 AC 1,166 ms
20,200 KB
testcase_13 AC 1,157 ms
12,488 KB
testcase_14 AC 860 ms
28,952 KB
testcase_15 AC 873 ms
28,920 KB
testcase_16 AC 72 ms
12,504 KB
testcase_17 AC 1,414 ms
21,044 KB
testcase_18 AC 72 ms
12,376 KB
testcase_19 AC 16 ms
8,400 KB
testcase_20 AC 17 ms
8,308 KB
testcase_21 AC 17 ms
8,224 KB
testcase_22 AC 1,262 ms
19,328 KB
testcase_23 AC 16 ms
8,372 KB
testcase_24 AC 634 ms
12,572 KB
testcase_25 AC 1,102 ms
20,256 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

h,w,x,y=map(int,input().split())
dx=[0,0,1,-1]
dy=[1,-1,0,0]
a=[list(map(int,input().split())) for i in range(h)]
d=[[0]*w for i in range(h)]
d[x-1][y-1]=1
hq=[(a[x-1][y-1],x-1,y-1)]
t,cnt=0,0
import heapq
while hq:
    p,x,y=heapq.heappop(hq)
    if cnt>0 and t<=a[x][y]:exit(print("No"))
    cnt+=1
    t+=a[x][y]
    for i in range(4):
        if 0<=x+dx[i]<h and 0<=y+dy[i]<w and d[x+dx[i]][y+dy[i]]==0:
            d[x+dx[i]][y+dy[i]]=1
            heapq.heappush(hq,(a[x+dx[i]][y+dy[i]],x+dx[i],y+dy[i]))
    
print("Yes")
0