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 kevin678sw at 2012-05-15 08:28:21 on Problem 1828
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <stdlib.h>
#include <string>
#define N 50000
using namespace std;

typedef struct node{
	int x; 
	int y;
}Node;

Node a[N];

bool cmp_x_y(Node a, Node b)
{
	if(a.x==b.x)
		return a.y<b.y;
	else
		return a.x<b.x;
} 

bool cmp_y_x(Node a, Node b)
{
	if(a.y==b.y)
		return a.x<b.y;
	else
		return a.y<b.y;
}

int main()
{
	//freopen("C:\\acm.txt","r",stdin);	
	int n=0;
	
	while(cin>>n && n!=0)
	{
		int sum=0;
		
		for(int i=0;i<n;i++)
		{	cin>>a[i].x>>a[i].y;	}
		
		sort(a,a+n,cmp_y_x);//y
		int x1=a[n-1].x, y1=a[n-1].y;
		sum++;
		
		sort(a,a+n,cmp_x_y);//x
		int x2=a[n-1].x, y2=a[n-1].y;
		if(x2>x1 || y2>y1)
			sum++;
			
		cout<<sum<<endl;
	}
	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