結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 58 ms
63,588 KB
testcase_01 AC 57 ms
63,588 KB
testcase_02 AC 56 ms
63,588 KB
testcase_03 AC 57 ms
63,588 KB
testcase_04 AC 57 ms
63,588 KB
testcase_05 AC 58 ms
63,588 KB
testcase_06 AC 56 ms
63,588 KB
testcase_07 AC 535 ms
80,648 KB
testcase_08 AC 92 ms
77,576 KB
testcase_09 AC 697 ms
81,648 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 687 ms
81,572 KB
testcase_14 AC 708 ms
98,064 KB
testcase_15 AC 717 ms
98,068 KB
testcase_16 AC 84 ms
77,996 KB
testcase_17 AC 1,188 ms
94,240 KB
testcase_18 AC 84 ms
78,000 KB
testcase_19 AC 57 ms
63,588 KB
testcase_20 WA -
testcase_21 AC 56 ms
63,588 KB
testcase_22 RE -
testcase_23 WA -
testcase_24 AC 435 ms
80,756 KB
testcase_25 AC 571 ms
80,836 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,px,py = heappop(heap)
    if now > mi:
        now += mi
        cnt += 1
    else:
        print('No')
        exit()
print('Yes')
0