Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register
北京大学《ACM/ICPC大学生程序设计竞赛训练》暑期课面向全球招生!

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:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator