結果
問題 | No.1949 足し算するだけのパズルゲーム(2) |
ユーザー | terasa |
提出日時 | 2022-05-23 15:40:44 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,181 bytes |
コンパイル時間 | 294 ms |
コンパイル使用メモリ | 81,464 KB |
実行使用メモリ | 130,140 KB |
最終ジャッジ日時 | 2023-10-20 17:30:02 |
合計ジャッジ時間 | 16,175 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | AC | 60 ms
65,896 KB |
testcase_02 | WA | - |
testcase_03 | WA | - |
testcase_04 | AC | 55 ms
65,896 KB |
testcase_05 | WA | - |
testcase_06 | AC | 56 ms
65,896 KB |
testcase_07 | WA | - |
testcase_08 | AC | 98 ms
79,040 KB |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | AC | 1,189 ms
86,076 KB |
testcase_14 | AC | 803 ms
124,780 KB |
testcase_15 | AC | 813 ms
124,776 KB |
testcase_16 | AC | 85 ms
78,524 KB |
testcase_17 | WA | - |
testcase_18 | AC | 80 ms
78,520 KB |
testcase_19 | AC | 55 ms
65,996 KB |
testcase_20 | WA | - |
testcase_21 | AC | 58 ms
65,996 KB |
testcase_22 | WA | - |
testcase_23 | WA | - |
testcase_24 | AC | 657 ms
83,664 KB |
testcase_25 | WA | - |
ソースコード
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 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, ac)) s = 0 for r in range(H): for c in range(W): s += A[r][c] print(s, player) print('Yes')