結果
| 問題 | No.2639 Longest Increasing Walk |
| コンテスト | |
| ユーザー |
寝癖
|
| 提出日時 | 2024-06-02 18:18:28 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 564 bytes |
| コンパイル時間 | 239 ms |
| コンパイル使用メモリ | 82,432 KB |
| 実行使用メモリ | 168,960 KB |
| 最終ジャッジ日時 | 2024-12-23 10:19:16 |
| 合計ジャッジ時間 | 9,916 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 30 RE * 3 |
ソースコード
from functools import lru_cache
H, W = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(H)]
@lru_cache(maxsize=None)
def dp(i, j):
# (i, j)からスタートして何マス歩けるか
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][j] < A[ni][nj]:
res = max(res, dp(ni, nj)+1)
return res
ans = 0
for i in range(H):
for j in range(W):
ans = max(ans, dp(i, j))
print(ans)
寝癖