UVa10763 - Foreign Exchange

1、pair的使用

2、vector的使用

3、sort

//#define LOCAL
#include<iostream>
#include<array>
#include<queue>
#include<vector>
#include<cmath>
#include<ctime>
#include<algorithm>
using namespace std;

typedef pair<int, int> P;
vector<P> s,s1;

int main(){
#ifdef LOCAL
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
#endif
	int n;
	while (cin >> n&&n){
		for (int i = 0; i < n; i++){
			P p,p1;
			scanf("%d%d", &p.first, &p.second);
			p1.first = p.second;
			p1.second = p.first;
			s.push_back(p);
			s1.push_back(p1);
		}
		sort(s.begin(), s.end());
		sort(s1.begin(), s1.end());
		if (s == s1) cout << "YES" << "\n";
		else cout << "NO" << "\n";
		s.clear();
		s1.clear();
	}
	//printf("Time used=%.3f\n", (double)clock() / CLOCKS_PER_SEC);
	return 0;
}

你可能感兴趣的:(uva,刘汝佳,C++与STL入门,算法竞赛入门经典第二版)