|
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <ctime>
#include <stack>
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.x,&a.y);
b.x = a.y;
b.y = a.x;
}
sort(a,a+n);
sort(b,b+n);
int flag = 1;
for(int i = 0;i < n;i++)
{
if(memcmp(&a,&b,sizeof(node)) != 0)
{
flag = 0;
}
}
if(flag)
printf("YES\n");
else
printf("NO\n");
}
return 0;
}</pre><pre code_snippet_id="640726" snippet_file_name="blog_20150410_3_4436580" name="code" class="cpp">我认为这种方法才是最符合题意的,虽然这里面数据很差,但是这种做法才是比较正确的! |
|