#include <iostream>
#include <stack>
#include <stdio.h>
using namespace std;
#define N 100002
int main()
{
int couple[2*N] = {0};
int n;
int a,b;
while(scanf("%d",&n) && n != 0)
{
stack<int> s;
for(int i = 0;i < n;i++)
{
cin >> a >> b;
couple[a] = b;//将夫妻编号关联起来
couple[b] = a;
}
for(int j = 1;j <= 2*n;j++)
{
if(!s.empty() && s.top() == couple[j])
s.pop();
else
s.push(j);
}
if(s.empty())
cout<<"Yes\n";
else
cout<<"No\n";
}
return 0;
}
sicily 1021.Couples
最新推荐文章于 2019-06-26 23:26:56 发布