Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
Register

## 贴上代码

Posted by 20152480225 at 2017-03-10 20:15:23 on Problem 1088
```#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const int maxn = 100+4;
int Map[maxn][maxn];
int d[maxn][maxn];
int r, c, ans;
int dr[4][2] = {{-1,0}, {0, -1}, {1, 0}, {0, 1}};

int dfs(int x, int y){
if(d[x][y] != 0){
return d[x][y];
}
d[x][y] = 1;
for (int i = 0; i < 4; ++i){
int mx = x + dr[i][0], my = y + dr[i][1];
if (mx >= 0 && my >= 0 && mx < r && my < c && Map[mx][my] < Map[x][y]){
d[x][y] = max(d[x][y], dfs(mx, my) + 1);
}
}
ans = max(ans, d[x][y]);
return d[x][y];
}

int main(){
while(~scanf("%d%d", &r, &c)){
for (int i = 0; i < r; ++i){
for (int j = 0; j < c; ++j){
scanf("%d", &Map[i][j]);
}
}
memset(d, 0, sizeof d );
ans = 1;
for (int i = 0; i < r; ++i){
for (int j = 0; j < c; ++j){
dfs(i , j);
}
}
printf("%d\n", ans);
//cout << ans << endl;
}

return 0;
}
//zzuwenjie```

Followed by: