結果
| 問題 | No.2639 Longest Increasing Walk |
| コンテスト | |
| ユーザー |
nonon
|
| 提出日時 | 2024-09-10 07:59:03 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 39 ms / 2,000 ms |
| コード長 | 697 bytes |
| コンパイル時間 | 2,080 ms |
| コンパイル使用メモリ | 191,208 KB |
| 最終ジャッジ日時 | 2025-02-24 06:29:32 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 33 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
int H,W,A[500][500],dp[500][500];
int dr[4]={1,0,-1,0},dc[4]={0,1,0,-1};
bool vis[500][500];
int dfs(int r, int c)
{
if(vis[r][c])return dp[r][c];
dp[r][c]=1;
for(int d=0;d<4;d++)
{
int tr=r+dr[d],tc=c+dc[d];
if(0<=tr&&tr<H&&0<=tc&&tc<W&&A[tr][tc]>A[r][c])
{
dp[r][c]=max(dp[r][c],dfs(tr,tc)+1);
}
}
vis[r][c]=true;
return dp[r][c];
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
cin>>H>>W;
for(int i=0;i<H;i++)for(int j=0;j<W;j++)cin>>A[i][j];
int ans=0;
for(int i=0;i<H;i++)for(int j=0;j<W;j++)ans=max(ans,dfs(i,j));
cout<<ans<<endl;
}
nonon