uva 10763

原题

简单题, 主要还是自定义一个类型装两个坐标(因为没法创建那么大的二维数组)

然后用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; 
}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值