简单题, 主要还是自定义一个类型装两个坐标(因为没法创建那么大的二维数组)
然后用map映射自定义类型来记录是否有出现过,
再有就是用一个count计数器, 出现新的坐标就+1, 匹配一对就-1, 以此来最后判断是否全部匹配了
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <cmath>
#include <deque>
#include <map>
#include <cassert>
#include <iomanip>
#include <list>
using namespace std;
const int MAXN = 500000+10;
typedef long long LL;
typedef long long Type;
/*
uva 10763
关键 : map映射(记录)自定义类型
*/
struct Point{
Type x;
Type y;
Point(const Type & a,const Type & b){
x = a;
y = b;
}
};
bool operator<(const Point & a,const Point & b){
if( a.x!=b.x ) return a.x<b.x;
else return a.y<b.y;
}
int main(){
// freopen("input2.txt","r",stdin);
int n;
map<Point,bool> mp;
while( cin>>n && n>0 ){
mp.clear();
int notMatch = 0;
Type a, b;
while( n-- ){
cin >> a >> b;
Point p2(b,a);
if( !mp[p2] ){
Point p1(a,b);
mp[p1] = true;
notMatch++;
}else{
notMatch--;
}
}
if( notMatch==0 ) cout << "YES" << endl;
else cout << "NO" << endl;
}
return 0;
}