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

圣母玛利亚 啊 !!!各种大神啊 我的为什么就 TLE

Posted by crazyyangdan at 2011-10-05 09:58:12 on Problem 1088
#include<iostream>
using namespace std;
int ans=1;
int map[120][120];
int F,R;

typedef struct
{
	int x;
	int y;
} Way;

Way way[4]={{0,1},{0,-1},{1,0},{-1,0}};
int temp;
void solve (int x,int y)
{
	int i;

	for(i=0;i<4;i++)
	{
		if(x+way[i].x>=1 && y+way[i].y>=1 && x+way[i].x<=F && y+way[i].y<=R && map[x][y]>map[x+way[i].x][y+way[i].y])
		{
			temp++;
			if(ans<temp)  ans=temp;
			solve(x+way[i].x ,y+way[i].y);
				temp--;
     
		
		}
    
	}
}
int main()
{
  
	cin>>F>>R;
	int i,j;
	for(i=1;i<=F;i++)
		for(j=1;j<=R;j++)
    scanf("%d",&map[i][j]);
	for(i=1;i<=F;i++)
		for(j=1;j<=R;j++)
		{
			temp=1;
			solve(i,j);
		}
	cout<<ans<<endl;
 
}

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