結果

問題 No.1948 足し算するだけのパズルゲーム(1)
ユーザー MasKoaTSMasKoaTS
提出日時 2022-05-20 22:57:19
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 1,303 bytes
コンパイル時間 226 ms
コンパイル使用メモリ 81,840 KB
実行使用メモリ 116,804 KB
最終ジャッジ日時 2023-10-20 13:49:44
合計ジャッジ時間 11,775 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 133 ms
92,648 KB
testcase_01 AC 123 ms
85,644 KB
testcase_02 AC 133 ms
85,640 KB
testcase_03 AC 132 ms
85,644 KB
testcase_04 AC 126 ms
85,640 KB
testcase_05 AC 127 ms
85,648 KB
testcase_06 AC 125 ms
85,640 KB
testcase_07 AC 278 ms
111,796 KB
testcase_08 AC 187 ms
102,924 KB
testcase_09 AC 289 ms
111,872 KB
testcase_10 AC 373 ms
112,108 KB
testcase_11 AC 254 ms
112,068 KB
testcase_12 AC 518 ms
112,320 KB
testcase_13 TLE -
testcase_14 AC 1,582 ms
113,192 KB
testcase_15 AC 223 ms
110,460 KB
testcase_16 AC 140 ms
88,616 KB
testcase_17 AC 137 ms
87,860 KB
testcase_18 AC 126 ms
85,632 KB
testcase_19 AC 129 ms
85,644 KB
testcase_20 TLE -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import itertools as iter
import collections as coll
import heapq as hq
import bisect as bis
from decimal import Decimal as dec
from functools import cmp_to_key
import math
import sys
#import pypyjit
#pypyjit.set_param('max_unroll_recursion=-1')
sys.setrecursionlimit(10 ** 6)
inp = sys.stdin.readline
input = lambda : inp().rstrip()
getN = lambda : int(inp())
getNs = lambda : map(int, inp().split())
getList = lambda :list(map(int, inp().split()))
getStrs = lambda n : [input() for _ in [0] * n]
def yexit(): print("Yes"); exit(0)
def nexit(): print("No"); exit(0)
pi = 3.141592653589793
mod = 1000000007
MOD = 998244353
INF = 4611686018427387903
dx = [1, 0, -1, 0];	dy = [0, 1, 0, -1]


"""
Main Code
"""

h, w = getNs()
a = [getList() for _ in [0] * h]

dp = [[[0] * 2 for _ in [0] * w] for _ in [0] * h]
dp[0][0] = a[0][0]
que = [(0, 0, a[0][0], 0)]
while(que):
	x, y, t, c = que.pop()
	for nx, ny in ((x + 1, y), (x, y + 1)):
		if not(0 <= nx < h and 0 <= ny < w):
			continue
		if(t > a[nx][ny] and t + a[nx][ny] > dp[nx][ny][c]):
			dp[nx][ny][c] = t + a[nx][ny]
			que.append((nx, ny, t + a[nx][ny], c))
		elif(c == 0 and (nx != h - 1 or ny != w - 1) and t > dp[nx][ny][1]):
			dp[nx][ny][1] = t
			que.append((nx, ny, t, 1))

if(dp[h - 1][w - 1][0] + dp[h - 1][w - 1][1] > 0):
	yexit()
nexit()
0