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 ReTleWa at 2019-07-10 09:49:07 on Problem 1088 and last updated at 2019-07-10 10:04:22
```#include <iostream>
#include <cstdio>
using namespace std;

const int maxn = 110;

int gra[maxn][maxn];
int record[maxn][maxn];

int R, C;

bool inner(int x, int y)
{
return x>=1&&x<=R&&y>=1&&y<=C;
}

int getMax(int x, int y)
{
if(record[x][y])
return record[x][y];
int maxx = 0;
if(inner(x+1,y)&&(gra[x+1][y]<gra[x][y])) maxx = max(maxx, getMax(x+1,y));
if(inner(x-1,y)&&(gra[x-1][y]<gra[x][y])) maxx = max(maxx, getMax(x-1,y));
if(inner(x,y+1)&&(gra[x][y+1]<gra[x][y])) maxx = max(maxx, getMax(x,y+1));
if(inner(x,y-1)&&(gra[x][y-1]<gra[x][y])) maxx = max(maxx, getMax(x,y-1));
return record[x][y] = 1 + maxx;
}

int main()
{
while(scanf("%d%d",&R,&C)!=EOF)
{
for(int i=1;i<=R;i++)
{
for(int j=1;j<=C;j++)
{
scanf("%d",&gra[i][j]);
record[i][j] = 0;
}
}
int res = 0;
for(int i=1;i<=R;i++)
{
for(int j=1;j<=C;j++)
{
res = max(res, getMax(i,j));
}
}
cout<<res<<endl;
}
return 0;
}```

Followed by: