結果
| 問題 | 
                            No.2639 Longest Increasing Walk
                             | 
                    
| コンテスト | |
| ユーザー | 
                             寝癖
                         | 
                    
| 提出日時 | 2024-06-02 18:21:41 | 
| 言語 | PyPy3  (7.3.15)  | 
                    
| 結果 | 
                             
                                RE
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 728 bytes | 
| コンパイル時間 | 356 ms | 
| コンパイル使用メモリ | 82,304 KB | 
| 実行使用メモリ | 117,856 KB | 
| 最終ジャッジ日時 | 2024-12-23 10:19:44 | 
| 合計ジャッジ時間 | 6,462 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge5 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 30 RE * 3 | 
ソースコード
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)
            
            
            
        
            
寝癖