結果
| 問題 | No.2639 Longest Increasing Walk |
| コンテスト | |
| ユーザー |
寝癖
|
| 提出日時 | 2024-06-02 18:21:41 |
| 言語 | PyPy3 (8.0.0 + ACL) |
| 結果 |
RE
不安定
|
| 実行時間 | - |
| コード長 | 728 bytes |
| 記録 | |
| コンパイル時間 | 198 ms |
| コンパイル使用メモリ | 82,548 KB |
| 実行使用メモリ | 122,080 KB |
| 最終ジャッジ日時 | 2026-10-06 12:03:06 |
| 合計ジャッジ時間 | 6,750 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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)
寝癖