排序就行了。。我想学map来着。。竟然没用的题解。哈希啥的。。
#include<cstdio>
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
const int maxn = 500000 + 5;
int main()
{
int a[maxn],b[maxn],n,mark;
while(cin >> n&&n)
{
mark = 0;
int x,y;
for(int i = 0;i < n; ++i)
{
scanf("%d%d",&x,&y);
a[i] = x,b[i] = y;
}
sort(a, a+n);sort(b,b+n);
for(int i = 0;i < n; ++i)
if(a[i]!=b[i]){mark = 1;break;}
if(mark==1)cout <<"NO" <<endl;
else cout<< "YES" <<endl;
}
}