2017.12.25
// 注意:输入0 0的时候也要输出 Yes
#include <iostream>
#include <algorithm>
#include <cstring>
#include <set>
using namespace std;
#define MAX 100000 + 5
int pre[MAX];
int out[MAX];
set<int> vertex;
void Init(int n){
for(int i = 1; i <= n; i++)
pre[i] = i;
}
int find1(int x){
int root = x;
while(pre[root] != root)
root = pre[root];
while(x != root){
int t = pre[x];
pre[x] = root;
x = t;
}
return root;
}
int find(int x){
if(pre[x] != x)
pre[x] = find(pre[x]);
return pre[x];
}
bool join(int x, int y){
int xx = find(x);
int yy = find(y);
if(xx != yy){
pre[xx] = yy;
return true;
}
return false;
}
int main(){
int a, b;
int e, v;
while(1){
cin >> a >> b;
if(a == -1 && b == -1)
break;
if(a == 0 && b == 0){
cout << "Yes" << endl;
continue;
}
Init(MAX);
vertex.clear();
memset(out, 0, sizeof(out));
e = 0;
v = 0;
while(1){
if(a == 0 && b == 0)
break;
vertex.insert(a);
vertex.insert(b);
e++;
join(a, b);
cin >> a >> b;
}
v = vertex.size();
set<int>::iterator it;
for(it = vertex.begin(); it != vertex.end(); it++){
out[find(*it)] = 1;
}
int cnt = 0;
for(it = vertex.begin(); it != vertex.end(); it++){
if(out[*it] == 1)
cnt++;
}
if(e + 1 == v && cnt == 1)
cout << "Yes" << endl;
else
cout << "No" << endl;
// cout << "--------------------" << endl;
// cout << "E: " << e << ' ' << "V: " << v << " cnt : " << cnt << endl;
// for(it = vertex.begin(); it != vertex.end(); it++)
// cout << *it << ":" << pre[*it] << endl;
//
// for(it = vertex.begin(); it != vertex.end(); it++)
// cout << *it << ":" << out[*it] << endl;
// cout << "--------------------" << endl;
}
return 0;
}