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 forceil at 2007-04-06 11:29:52 on Problem 1088
#include <iostream.h>
#include <stdlib.h>
int Data[100][100];
int R,C;
int Max_len=0;
int Temp_len=0;
int Go(int x,int y);
int main(int argc, char *argv[])
{
	cin>>R>>C;
	int i,j;

	for(i=0;i<R;i++)
	{
		for(j=0;j<C;j++)
		cin>>Data[i][j];
	}


	for(i=0;i<R;i++)
	{
		for(j=0;j<C;j++)
		{
			Temp_len=Go(i,j);
			if(Max_len<Temp_len)
			Max_len=Temp_len;
		}
	}

	cout<<Max_len;
  return EXIT_SUCCESS;
}
int Go(int x,int y)
{
	if(Data[x][y]<0)
	return -Data[x][y];
	
	int t=0;
	int len=0;
	int temp=0;
	while(t<4)
	{
	temp=0;
		switch(t)
		{
			case 0:
			if(x==0)
			break;
			else if(Data[x-1][y]<Data[x][y])
			temp=Go(x-1,y);
			break;
			case 1:
			if(y==(C-1))
			break;
			else if(Data[x][y+1]<Data[x][y])
			temp=Go(x,y+1);
			break;
			case 2:
			if(x==(R-1))
			break;
			else if(Data[x+1][y]<Data[x][y])
			temp=Go(x+1,y);
			break;
			case 3:
			if(y==0)
			break;
			else if(Data[x][y-1]<Data[x][y])
			temp=Go(x,y-1);
			break;
		}
		if(temp>len)
		len=temp;
		t++;
	}
	len+=1;
	Data[x][y]=-len;
	return len;
}

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