結果
問題 |
No.2639 Longest Increasing Walk
|
ユーザー |
![]() |
提出日時 | 2024-06-02 18:21:59 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 720 bytes |
コンパイル時間 | 608 ms |
コンパイル使用メモリ | 82,048 KB |
実行使用メモリ | 723,936 KB |
最終ジャッジ日時 | 2024-12-23 10:19:58 |
合計ジャッジ時間 | 12,388 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 31 TLE * 1 MLE * 1 |
ソースコード
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)