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 |
为什么不对,各位大神帮忙看一下#include<stdio.h> int a[120][120],r,c; int dp[120][120]; int dx[4]={0,-1,1,0},dy[4]={-1,0,0,1}; int OK(int i,int j) { if(i>=1&&i<=r&&j>=1&&j<=c) return 1; return 0; } int Max(int i,int j) { int k,max1,max=1; if(dp[i][j]>0) return dp[i][j]; for(k=0;k<4;k++){ if(OK(i+dx[k],j+dy[k])){ if(a[i][j]>a[i+dx[k]][j+dy[k]]) max1=Max(i+dx[k],j+dy[k])+1; if(max<max1) max=max1; } } dp[i][j]=max; return max; } int main() { int i,j,max,max1; while(scanf("%d%d",&r,&c)!=EOF) { max=max1=0; for(i=1;i<=r;i++) for(j=1;j<=c;j++) { scanf("%d",&a[i][j]); dp[i][j]=0; } for(i=1;i<=r;i++) { for(j=1;j<=c;j++) { max1=Max(i,j); if(max<max1) max=max1; } } printf("%d\n",max); } return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator