結果
| 問題 | 
                            No.2639 Longest Increasing Walk
                             | 
                    
| コンテスト | |
| ユーザー | 
                             timi
                         | 
                    
| 提出日時 | 2024-02-19 21:59:31 | 
| 言語 | PyPy3  (7.3.15)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 398 ms / 2,000 ms | 
| コード長 | 584 bytes | 
| コンパイル時間 | 174 ms | 
| コンパイル使用メモリ | 82,376 KB | 
| 実行使用メモリ | 137,492 KB | 
| 最終ジャッジ日時 | 2024-09-29 01:58:16 | 
| 合計ジャッジ時間 | 6,547 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge5 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 33 | 
ソースコード
H,W=map(int, input().split())
A=[];B=[];D={}
for i in range(H):
  AA=list(map(int, input().split()))
  A.append(AA)
  for j in range(W):
    a=AA[j]
    if a not in D:
      D[a]=[]
      B.append(a)
    D[a].append((i,j))
B=sorted(B)
dp=[[1]*W for _ in range(H)]
dy,dx=[1,-1,0,0],[0,0,1,-1]
for b in B:
  if b==1:
    continue 
  for y,x in D[b]:
    for i in range(4):
      ny,nx=y+dy[i],x+dx[i]
      if 0<=ny<H and 0<=nx<W and A[ny][nx]<A[y][x]:
        dp[y][x]=max(dp[y][x],dp[ny][nx]+1)
ans=0
for h in range(H):
  for w in range(W):
    ans=max(ans,dp[h][w])
print(ans)
    
            
            
            
        
            
timi