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

自己已解决,只要在Max函数中的max1后加上=1,即max1=1;就行。

Posted by 31201153 at 2013-05-27 18:02:13 on Problem 1088
In Reply To:为什么不对,各位大神帮忙看一下 Posted by:31201153 at 2013-05-26 10:40:14
> #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=1,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:
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