結果

問題 No.1949 足し算するだけのパズルゲーム(2)
ユーザー terasaterasa
提出日時 2022-05-23 16:27:50
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 821 ms / 3,000 ms
コード長 964 bytes
コンパイル時間 202 ms
コンパイル使用メモリ 81,596 KB
実行使用メモリ 105,536 KB
最終ジャッジ日時 2023-10-20 17:35:49
合計ジャッジ時間 7,562 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 57 ms
66,016 KB
testcase_01 AC 54 ms
66,016 KB
testcase_02 AC 53 ms
66,016 KB
testcase_03 AC 53 ms
66,016 KB
testcase_04 AC 56 ms
66,016 KB
testcase_05 AC 54 ms
66,016 KB
testcase_06 AC 61 ms
66,016 KB
testcase_07 AC 518 ms
83,404 KB
testcase_08 AC 90 ms
79,088 KB
testcase_09 AC 394 ms
83,376 KB
testcase_10 AC 392 ms
83,356 KB
testcase_11 AC 416 ms
83,504 KB
testcase_12 AC 407 ms
83,260 KB
testcase_13 AC 451 ms
83,332 KB
testcase_14 AC 338 ms
105,536 KB
testcase_15 AC 332 ms
105,536 KB
testcase_16 AC 84 ms
78,572 KB
testcase_17 AC 821 ms
104,704 KB
testcase_18 AC 84 ms
78,564 KB
testcase_19 AC 59 ms
66,016 KB
testcase_20 AC 57 ms
66,016 KB
testcase_21 AC 55 ms
66,016 KB
testcase_22 AC 569 ms
99,456 KB
testcase_23 AC 56 ms
66,016 KB
testcase_24 AC 270 ms
82,824 KB
testcase_25 AC 451 ms
83,304 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
import pypyjit
import itertools
import heapq
import math
from collections import deque, defaultdict, Counter
import string
import random

input = sys.stdin.readline
sys.setrecursionlimit(10 ** 6)
pypyjit.set_param('max_unroll_recursion=-1')


H, W, R, C = map(int, input().split())
R -= 1
C -= 1
A = [list(map(int, input().split())) for _ in range(H)]


player = A[R][C]
h = [(0, R * W + C)]
darr = [(1, 0), (0, 1), (-1, 0), (0, -1)]
flag = [[False for _ in range(W)] for _ in range(H)]

while len(h) > 0:
    enemy, hash_ = heapq.heappop(h)
    r, c = divmod(hash_, W)
    if flag[r][c] is True:
        continue
    if player <= enemy:
        print('No')
        exit()
    player += enemy
    flag[r][c] = True

    for dr, dc in darr:
        ar, ac = r + dr, c + dc
        if ar < 0 or ar > H - 1 or ac < 0 or ac > W - 1:
            continue
        if flag[ar][ac] is False:
            heapq.heappush(h, (A[ar][ac], ar * W + ac))
print('Yes')
0