結果
| 問題 |
No.1949 足し算するだけのパズルゲーム(2)
|
| コンテスト | |
| ユーザー |
terasa
|
| 提出日時 | 2022-05-23 16:25:32 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 982 bytes |
| コンパイル時間 | 264 ms |
| コンパイル使用メモリ | 81,920 KB |
| 実行使用メモリ | 80,128 KB |
| 最終ジャッジ日時 | 2024-09-20 13:12:54 |
| 合計ジャッジ時間 | 3,665 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 14 WA * 12 |
ソースコード
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)]
flag[R][C] = True
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')
terasa