uva 10763 Foreign Exchange我认为我这种做法最符合题意!

#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
using namespace std;
//freopen("out.txt","w",stdout);
//freopen("in.txt","r",stdin);
//ios::sync_with_stdio(false);
struct node{
	int x,y;
	bool operator < (const node& a)const {
		if(x == a.x )
			return y < a.y;
		else
			return x < a.x;
	}
};
node a[500005];
node b[500005];


int main()
{
	int n;
	

	while(scanf("%d",&n),n)
	{
		for(int i = 0;i < n;i++)
		{
			scanf("%d%d",&a[i].x,&a[i].y);
			b[i].x = a[i].y;
			b[i].y = a[i].x;
		}
		sort(a,a+n);
		sort(b,b+n);
		int flag = 1;
		for(int i = 0;i < n;i++)
		{
			if(memcmp(&a[i],&b[i],sizeof(node)) != 0)
			{
				flag = 0;
			}
		}
		if(flag)
		   printf("YES\n");
        else
            printf("NO\n");
	}
	return 0;
}
我认为这种方法才是最符合题意的,虽然这里面数据很差,但是这种做法才是比较正确的!

你可能感兴趣的:(uva 10763 Foreign Exchange我认为我这种做法最符合题意!)