题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1272
#include<bits/stdc++.h>
using namespace std;
#define debug puts("YES");
#define rep(x,y,z) for(int (x)=(y);(x)<(z);(x)++)
#define ll long long
#define lrt int l,int r,int rt
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define root l,r,rt
#define mst(a,b) memset((a),(b),sizeof(a))
#define pii pair<ll,ll>
#define mk(x,y) make_pair(x,y)
const int mod=998244353;
const int maxn=2e5+9;
const int ub=1e6;
ll powmod(ll x,ll y){ll t; for(t=1;y;y>>=1,x=x*x%mod) if(y&1) t=t*x%mod; return t;}
ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
int a,b,flag;
int fa[maxn],vis[maxn];
int Find(int x){
return fa[x]==x?x:fa[x]=Find(fa[x]);
}
int Union(int x,int y){
int tx=Find(x),ty=Find(y);
if(tx!=ty) fa[tx]=ty;
else return 0;
return 1;
}
int main(){
while(scanf("%d%d",&a,&b)&&(a!=-1&&b!=-1)){
if(a==0&&b==0) {puts("Yes");continue;}///判定其是否为空
rep(i,0,maxn) fa[i]=i;///
mst(vis,0);///初始化
flag=1;
Union(a,b);///合并
vis[a]=vis[b]=1;
while(scanf("%d%d",&a,&b)&&(a+b)){
vis[a]=vis[b]=1;
if(!Union(a,b)) flag=0;///判环的存在
}
int tmp=0;for(int i=0;i<maxn;i++) if(vis[i]) if(fa[i]==i) tmp++;///判定是否只有一个连通块
if(tmp!=1) flag=0;
if(flag) puts("Yes");
else puts("No");
}
return 0;
}