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 suyan at 2010-05-25 21:31:31 on Problem 1828
先对X排序 再对相同X的Y排序
#include<iostream>
#include<algorithm>

using namespace std;
#define mmax 50050
struct node
{
	int x,y;

}nod,tem,aa[mmax];
int n;
int num;
bool cmpx(node a,node b)
{
	if(a.x>b.x)
       return 0;
	else
		return 1;
}//why? 0 1 exchange

bool cmpy(node a,node b)
{
	if(a.x==b.x)
		if(a.y>=b.y)
			return 1;
		else return 0;
		return 1;
}

void init()
{
	
	sort(aa,aa+n,cmpx);

    sort(aa,aa+n,cmpy);


}
int main()
{   num=0;
	n=0;
	while(1)
	{
		cin>>n;
		if(!n)
			break;
		int i;
		for(i=0;i<n;i++)
			cin>>aa[i].x>>aa[i].y;
		init();
  
		int maxy=aa[0].y;
	
			num=1;
	
		for(i=1;i<n;i++)
			{ 
				if(aa[i].x==aa[i-1].x)
					continue;
				else
				{
					if(aa[i].y>maxy)
					{	num++;maxy=aa[i].y;}
					  
				}
			}
		cout<<num<<endl;
	}
	return 1;
}

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