-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1088.cpp
More file actions
71 lines (60 loc) · 1.14 KB
/
Copy path1088.cpp
File metadata and controls
71 lines (60 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#include<iostream>
using namespace std;
struct list_t{
int height;
int i;
int j;
};
int maxlen=0;
int heigth[101][101];
int ans[101][101];
int row;
int colume;
int calculate(int i,int j)
{
int local_max=1;
int t;
if(ans[i][j]!=0){
return ans[i][j];
}
if(i>0&&heigth[i-1][j]>heigth[i][j]){
t=calculate(i-1,j)+1;
if(t>local_max)local_max=t;
}
if(j>0&&heigth[i][j-1]>heigth[i][j]){
t=calculate(i,j-1)+1;
if(t>local_max)local_max=t;
}
if(i<row-1&&heigth[i+1][j]>heigth[i][j]){
t=calculate(i+1,j)+1;
if(t>local_max)local_max=t;
}
if(j<colume-1&&heigth[i][j+1]>heigth[i][j]){
t=calculate(i,j+1)+1;
if(t>local_max)local_max=t;
}
ans[i][j]=local_max;
if(ans[i][j]>maxlen)maxlen=ans[i][j];
return ans[i][j];
}
int main()
{
int i,j;
memset(heigth,0,sizeof(heigth));
memset(ans,0,sizeof(ans));
cin>>row>>colume;
for(i=0;i<row;i++){
for(j=0;j<colume;j++){
cin>>heigth[i][j];
}
}
for(i=0;i<row;i++){
for(j=0;j<colume;j++){
if(0==ans[i][j]){
calculate(i,j);
}
}
}
cout<<maxlen<<endl;
return 0;
}