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

求出错数据。。。

Posted by 8085 at 2006-04-22 21:17:53 on Problem 1088
#include <iostream.h>
#include <stdlib.h>
#include <math.h>
struct point
{
	int x,y,high,num;
}p[10005];
int cmp(const void * a,const void * b)
{
	return -(*((point *)a)).high+(*((point *)b)).high;
}
int max[10005]={0},sum;
void main()
{
	int R,C,i,j,k=0;
	cin >>R>>C;
	sum=R*C;
	for(i=0;i<R;i++)
		for(j=0;j<C;j++)
		{
			cin >>p[k].high;
			p[k].x=i;
			p[k].y=j;
			k++;
		}
	qsort(p,sum,sizeof(p[0]),cmp);
	for(i=0;i<sum;i++)
		p[i].num=i;
	max[0]=1;
	for(i=1;i<sum;i++)
	{
		for(j=0;j<i;j++)
		{
			int t=abs(p[i].x-p[j].x),s=abs(p[i].y-p[j].y);
			if(t*s==0&&t<=1&&s<=1&&p[j].high>p[i].high)
			{
				k=1+max[j];
				if(k>max[i]) max[i]=k;
			}
		}
	}
	int big=max[sum-1];
	for(i=sum-2;i>=0;i--)
	{
		if(p[i].high!=p[sum-1].high)
			break;
		else if(max[i]>big)
			big=max[i];
	}
	cout <<big<<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