//简单利用栈的功能解决就好
//开始时候录入cp关系可以利用数组录入相应的关系
#include "iostream"
#include "stack"
#include "cstring"
using namespace std;
int main(){
int c;
int couple[200002];
while(cin>>c&&c!=0){
stack<int>s;
memset(couple,0,sizeof(couple));
for (int i = 0; i < c; ++i)
{
int t,x;
cin>>t>>x;
couple[t]=x;
couple[x]=t;
}
for (int i = 1; i <= 2*c; ++i)
{
if(!s.empty()&&s.top()==couple[i]){
s.pop();
}else{
s.push(i);
}
}
if(s.empty()){
cout<<"Yes"<<endl;
}else{
cout<<"No"<<endl;
}
}
}
sicily1021-couples
最新推荐文章于 2019-06-26 23:26:56 发布