Foreign Exchange uva 10763


#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <algorithm>
#include <vector>
#include <cstring>
#include <stack>
#include <cctype>
#include <utility>   
#include <map>
#include <string>  
#include <climits> 
#include <set>
#include <string> 
#include <sstream>
#include <utility>
#include <ctime>

using std::priority_queue;
using std::vector;
using std::swap;
using std::stack;
using std::sort;
using std::max;
using std::min;
using std::pair;
using std::map;
using std::string;
using std::cin;
using std::cout;
using std::set;
using std::queue;
using std::string;
using std::istringstream;
using std::make_pair;
using std::greater;

const int MAXN(500010);

struct NODE
{
	int a, b;
	friend bool operator != (const NODE &op1, const NODE &op2)
	{
		return !(op1.a == op2.a && op1.b == op2.b);
	}
	friend bool operator < (const NODE &op1, const NODE &op2)
	{
		return op1.a == op2.a? (op1.b < op2.b): (op1.a < op2.a);
	}
};

NODE arr1[MAXN], arr2[MAXN];

int main()
{
	int n;
	while(scanf("%d", &n), n)
	{
		for(int i = 1; i <= n; ++i)
		{
			scanf("%d%d", &arr1[i].a, &arr1[i].b);
			arr2[i].a = arr1[i].b;
			arr2[i].b = arr1[i].a;
		}
		sort(arr1+1, arr1+1+n);
		sort(arr2+1, arr2+1+n);
		int flag = 1;
		while(flag <= n)
		{
			if(arr1[flag] != arr2[flag])
				break;
			++flag;
		}
		if(flag > n)
			printf("YES\n");
		else
			printf("NO\n");
	}
	return 0;
}


你可能感兴趣的:(Foreign Exchange uva 10763)