結果
| 問題 | No.2639 Longest Increasing Walk |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-02-19 23:08:27 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 775 bytes |
| 記録 | |
| コンパイル時間 | 1,377 ms |
| コンパイル使用メモリ | 168,636 KB |
| 実行使用メモリ | 13,760 KB |
| 最終ジャッジ日時 | 2024-09-29 02:49:17 |
| 合計ジャッジ時間 | 5,034 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 5 TLE * 1 -- * 27 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define REP(i,n) for(int i=0;i<int(n);i++)
int a[510][510],v[510][510];
int mx=0;
int H,W;
bool inside(int i,int j){
return (1<=i && i<=H && 1<=j && j<=W);
}
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
void dfs(int x,int y,int d){
v[x][y]=1;
mx=max(mx,d);
REP(k,4){
int p=x+dx[k],q=y+dy[k];
if(!inside(p,q)) continue;
if(v[p][q]==1) continue;
if(a[x][y]<a[p][q]) dfs(p,q,d+1);
v[x][y]=0;
}
}
int main(){
cin.tie(nullptr); ios_base::sync_with_stdio(false);
int i,j;
cin >> H >> W;
for(i=1;i<=H;i++) for(j=1;j<=W;j++) cin >> a[i][j];
for(i=1;i<=H;i++) for(j=1;j<=W;j++){
if(v[i][j]==0) dfs(i,j,1);
}
cout << mx << endl;
return 0;
}