Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
help有大佬帮我看下这个为什么错了吗?明明样例过了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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator