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

help

Posted by nohaeqstr at 2019-03-14 14:17:38 on Problem 1088
```有大佬帮我看下这个为什么错了吗？明明样例过了QAQ
#include<cstdio>
#include<cstring>
using namespace std;
int p[4][2]={{1,0},{-1,0},{0,1},{0,-1}};
int h[101][101];
int dp[101][101];
int m,n;
int max(int a,int b){if(a>b)return a;return b;}
int find(int x,int y){
for(int i=0;i<4;i++){
if(x+p[i][0]>m||x+p[i][0]<1||y+p[i][1]<1||y+p[i][1]>n) continue;
if(h[x][y]>h[x+p[i][0]][y+p[i][1]])
dp[x][y]=max(dp[x][y],dp[x+p[i][0]][y+p[i][1]]+1);
}
return h[x][y];
}
int main(){
scanf("%d %d",&m,&n);
for(int i=1;i<=m;i++)
for(int j=1;j<=n;j++)
scanf("%d",&h[i][j]);
int ans=0;
memset(dp,1,sizeof(dp));
for(int i=1;i<=m;i++)
for(int j=1;j<=n;j++){
dp[i][j]=find(i,j);
if(dp[i][j]>ans) ans=dp[i][j];
}
printf("%d\n",ans);
return 0;
}
```

Followed by: