結果
| 問題 | No.2639 Longest Increasing Walk |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-02-19 21:37:31 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
AC
|
| 実行時間 | 323 ms / 2,000 ms |
| コード長 | 627 bytes |
| 記録 | |
| コンパイル時間 | 409 ms |
| コンパイル使用メモリ | 85,148 KB |
| 実行使用メモリ | 123,044 KB |
| 最終ジャッジ日時 | 2026-04-15 13:05:32 |
| 合計ジャッジ時間 | 5,635 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 33 |
ソースコード
H,W = list(map(int,input().split()))
A = [list(map(int,input().split())) for i in range(H)]
B = []
for i in range(H):
for j in range(W):
B.append((A[i][j],i,j))
B.sort(key=lambda x:x[0])
from collections import defaultdict
DP = [[0]*W for i in range(H)]
ans = 0
for a, i, j in B:
dp = 0
if i > 0 and A[i-1][j] < a:
dp = max(DP[i-1][j], dp)
if j > 0 and A[i][j-1] < a:
dp = max(DP[i][j-1], dp)
if i < H-1 and A[i+1][j] < a:
dp = max(DP[i+1][j], dp)
if j < W-1 and A[i][j+1] < a:
dp = max(DP[i][j+1], dp)
DP[i][j] = dp + 1
ans = max(dp+1,ans)
print(ans)