-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1021.cpp
More file actions
36 lines (34 loc) · 699 Bytes
/
Copy path1021.cpp
File metadata and controls
36 lines (34 loc) · 699 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include<iostream>
#include<stack>
using namespace std;
int couples[200001];
int main()
{
while(true)
{
int n;
cin>>n;
if(n == 0)
break;
stack<int> my;
for(int i = 0; i < n; i++)
{
int a,b;
cin>>a>>b;
couples[a] = b;
couples[b] = a;
}
for(int i = 1; i <= n*2; i++)
{
if(!my.empty() && my.top() == couples[i])
my.pop();
else
my.push(i);
}
if(my.size()==0)
cout<<"Yes"<<endl;
else
cout<<"No"<<endl;
}
return 0;
}