結果

問題 No.1949 足し算するだけのパズルゲーム(2)
ユーザー terasaterasa
提出日時 2022-05-23 15:06:32
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 1,048 bytes
コンパイル時間 146 ms
コンパイル使用メモリ 81,536 KB
実行使用メモリ 65,980 KB
最終ジャッジ日時 2023-10-20 17:28:50
合計ジャッジ時間 5,610 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 53 ms
65,980 KB
testcase_01 AC 53 ms
65,980 KB
testcase_02 AC 53 ms
65,980 KB
testcase_03 AC 53 ms
65,980 KB
testcase_04 AC 52 ms
65,980 KB
testcase_05 AC 56 ms
65,980 KB
testcase_06 AC 51 ms
65,980 KB
testcase_07 TLE -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
権限があれば一括ダウンロードができます

ソースコード

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 = []
darr = [(1, 0), (0, 1), (-1, 0), (0, -1)]
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
    heapq.heappush(h, (A[ar][ac], ar, ac))
flag = [[False for _ in range(W)] for _ in range(H)]
flag[R][C] = True

while len(h) > 0:
    enemy, r, c = heapq.heappop(h)
    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[r][c], ar, ac))
print('Yes')
0