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

哈哈,我爱暴力594ms

Posted by v8786339 at 2009-07-28 15:17:40 on Problem 1088
#include <iostream>
using namespace std;
int main()
{
	int hang,lie,hight[101][101],max=1,Continue=1;
	long path[101][101];
	cin >> hang >> lie;
	for (int i=0;i<hang;i++)
	{
		for(int j=0;j<lie;j++)
		{
			path[i][j]=1;
		}
	}
	for (int i=0;i<hang;i++)
	{
		for(int j=0;j<lie;j++)
		{
			cin >> hight[i][j];
		}
	}
	while (Continue)
	{
		Continue=0;
		for (int i=0;i<hang;i++)
			for(int j=0;j<lie;j++)
			{
				// to one point,but the directions??
				if (j>0) if (hight[i][j]>hight[i][j-1]) if (path[i][j-1]>path[i][j]-1) 
				{
					Continue=1;
					path[i][j]=path[i][j-1]+1;
					if (max<path[i][j]) max=path[i][j];
				}
				if (j<lie-1) if (hight[i][j]>hight[i][j+1]) if (path[i][j+1]>path[i][j]-1) 
				{
					Continue=1;
					path[i][j]=path[i][j+1]+1;
					if (max<path[i][j]) max=path[i][j];
				}
				if (i>0) if (hight[i][j]>hight[i-1][j]) if (path[i-1][j]>path[i][j]-1) 
				{
					Continue=1;
					path[i][j]=path[i-1][j]+1;
					if (max<path[i][j]) max=path[i][j];
				}
				if (i<hang-1) if (hight[i][j]>hight[i+1][j]) if (path[i+1][j]>path[i][j]-1) 
				{
					Continue=1;
					path[i][j]=path[i+1][j]+1;
					if (max<path[i][j]) max=path[i][j];
				}

			}
	}
	cout <<max;
	system("pause");
	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