Skip to content

Instantly share code, notes, and snippets.

@KT-Yeh
Last active August 29, 2015 13:56
Show Gist options
  • Save KT-Yeh/9045449 to your computer and use it in GitHub Desktop.
Save KT-Yeh/9045449 to your computer and use it in GitHub Desktop.
#include <cstdio>
#include <algorithm>
using namespace std;
int N;
int origin[500001], target[500001];
int main()
{
while (scanf("%d",&N)){
if (!N) break;
for (int i=0; i<N; i++)
scanf("%d %d",&origin[i],&target[i]);
if (N % 2) {
printf("NO\n");
continue;
}
sort(origin, origin+N, cmp);
sort(target, target+N, cmp);
bool yes = 1;
for (int i=0; i<N; i++)
if (origin[i] != target[i])
yes = 0;
printf("%s\n", yes ? "YES" : "NO");
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment