【链接】 我是链接,点我呀:)
【题意】
【题解】
如果x>y 则num[(x,y)]--; 否则num[(x,y)]++; 看看每一个二元组的num值是不是都为0就好。【代码】
#include <bits/stdc++.h>
using namespace std;
int n;
map <pair<int, int>, int> mmap;
int main()
{
//freopen("F:\rush.txt", "r", stdin);
while (~scanf("%d", &n) && n)
{
mmap.clear();
for (int i = 0; i < n; i++)
{
int x, y;
scanf("%d%d", &x, &y);
if (x > y)
{
swap(x, y);
mmap[make_pair(x, y)]--;
}
else
mmap[make_pair(x, y)]++;
}
bool ok = true;
for (auto temp : mmap)
{
if (temp.second!=0)
{
ok = false;
break;
}
}
if (ok)
puts("YES");
else
puts("NO");
}
return 0;
}