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

求教大牛...这段代码为何WA...不胜感激....

Posted by kamake at 2010-12-22 21:21:00 on Problem 1088
#include<stdio.h>
int num[100][100];
int length[100][100];
int r,c;
int getLength(int i,int j)
{
 	 if(length[i][j]>0)
 	 {
           return length[i][j];
	 }
	 int max=0;
	 if((i!=0)&&(num[i][j]>num[i-1][j]))
	 {
		int x=getLength(i-1,j)+1;
		if(max<x)
		{
		 		 max=x;
		}
	 }
	 if((i!=r-1)&&(num[i][j]>num[i+1][j]))
	 {
         int x=getLength(i+1,j)+1;
         if(max<x)
         {
		  		  max=x;
		 }
	 }
	 if((j!=0)&&(num[i][j]>num[i][j-1]))
	 {
		 int x=getLength(i,j-1)+1;
		 if(max<x)
		 {
		  		  max=x;
		 }
	 }
	 if((j!=r-1)&&(num[i][j]>num[i][j+1]))
	 {
          int x=getLength(i,j+1)+1;
          if(max<x)
          {
		   		   max=x;
		  }
	 }
	 return max;
}
int main()
{
    scanf("%d",&r);
    scanf("%d",&c);
 	int i,j;
 	for(i=0;i<r;i++)
 	{
		for(j=0;j<c;j++)
		{
		    scanf("%d",&num[i][j]);
		    length[i][j]=0;
		}
    }
    int maxLen=0;
    for(i=0;i<r;i++)
    {
		for(j=0;j<c;j++)
		{
		    length[i][j]=getLength(i,j);
		    if(maxLen<length[i][j])
		    {
			   maxLen=length[i][j];
			}
		}
	}
	printf("%d\n",maxLen+1);
  	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