結果

問題 No.2639 Longest Increasing Walk
ユーザー 寝癖寝癖
提出日時 2024-06-02 18:21:59
言語 PyPy3
(7.3.15)
結果
MLE  
実行時間 -
コード長 720 bytes
コンパイル時間 344 ms
コンパイル使用メモリ 82,384 KB
実行使用メモリ 679,844 KB
最終ジャッジ日時 2024-06-02 18:22:06
合計ジャッジ時間 5,757 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 43 ms
60,800 KB
testcase_01 AC 46 ms
54,912 KB
testcase_02 AC 44 ms
55,424 KB
testcase_03 AC 42 ms
54,656 KB
testcase_04 AC 228 ms
118,256 KB
testcase_05 AC 434 ms
133,204 KB
testcase_06 AC 418 ms
141,520 KB
testcase_07 MLE -
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 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

from functools import lru_cache

from sys import setrecursionlimit
import pypyjit
setrecursionlimit(10 ** 7)
pypyjit.set_param('max_unroll_recursion=-1')

H, W = map(int, input().split())
A = sum([list(map(int, input().split())) for _ in range(H)], [])

@lru_cache(maxsize=None)
def dp(x):
    # (i, j)からスタートして何マス歩けるか
    i, j = divmod(x, W)
    res = 1
    for dx, dy in [(1, 0), (-1, 0), (0, 1), (0, -1)]:
        ni, nj = i+dx, j+dy
        if not (0 <= ni < H and 0 <= nj < W):
            continue
        if A[i*W+j] < A[ni*W+nj]:
            res = max(res, dp(ni*W+nj)+1)
    return res

ans = 0
for i in range(H):
    for j in range(W):
        ans = max(ans, dp(i*W+j))

print(ans)
0