結果
| 問題 | No.2639 Longest Increasing Walk |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-02-19 21:37:31 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 482 ms / 2,000 ms |
| コード長 | 627 bytes |
| 記録 | |
| コンパイル時間 | 294 ms |
| コンパイル使用メモリ | 82,412 KB |
| 実行使用メモリ | 121,884 KB |
| 最終ジャッジ日時 | 2024-09-29 01:33:47 |
| 合計ジャッジ時間 | 7,367 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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)