結果

問題 No.1949 足し算するだけのパズルゲーム(2)
ユーザー siganaisiganai
提出日時 2022-05-20 23:06:09
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,096 ms / 3,000 ms
コード長 809 bytes
コンパイル時間 267 ms
コンパイル使用メモリ 81,736 KB
実行使用メモリ 98,692 KB
最終ジャッジ日時 2023-10-20 13:59:50
合計ジャッジ時間 10,073 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 60 ms
63,636 KB
testcase_01 AC 60 ms
63,636 KB
testcase_02 AC 59 ms
63,636 KB
testcase_03 AC 59 ms
63,636 KB
testcase_04 AC 59 ms
63,636 KB
testcase_05 AC 59 ms
63,636 KB
testcase_06 AC 60 ms
63,636 KB
testcase_07 AC 446 ms
80,052 KB
testcase_08 AC 94 ms
77,592 KB
testcase_09 AC 526 ms
80,452 KB
testcase_10 AC 580 ms
80,636 KB
testcase_11 AC 619 ms
80,836 KB
testcase_12 AC 600 ms
81,064 KB
testcase_13 AC 615 ms
80,852 KB
testcase_14 AC 726 ms
98,692 KB
testcase_15 AC 721 ms
98,692 KB
testcase_16 AC 86 ms
78,012 KB
testcase_17 AC 1,096 ms
94,096 KB
testcase_18 AC 88 ms
77,992 KB
testcase_19 AC 57 ms
63,636 KB
testcase_20 AC 58 ms
63,636 KB
testcase_21 AC 59 ms
63,636 KB
testcase_22 AC 866 ms
88,984 KB
testcase_23 AC 59 ms
63,636 KB
testcase_24 AC 363 ms
79,888 KB
testcase_25 AC 462 ms
80,404 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/env PyPy3

from collections import Counter, defaultdict, deque
import itertools
import re
import math
from functools import reduce
import operator
import bisect
from heapq import *
import functools
mod=998244353

import sys
input=sys.stdin.readline
h,w,y,x=map(int,input().split())
a=[list(map(int,input().split())) for _ in range(h)]
now = a[y-1][x-1]
heap = []
dx = [1,-1,0,0]
dy = [0,0,1,-1]
a[y-1][x-1] = -1
py,px=y-1,x-1
cnt = 1
while cnt < h * w:
    for i in range(4):
        ny,nx=dy[i]+py,dx[i]+px
        if 0 <= ny < h and 0 <= nx < w:
            if a[ny][nx] != -1:
                heappush(heap,[a[ny][nx],ny,nx])
                a[ny][nx] = -1
    mi,py,px = heappop(heap)
    if now > mi:
        now += mi
        cnt += 1
    else:
        print('No')
        exit()
print('Yes')
0