判空是否成树
#include <bits/stdc++.h>
#define MAX_N 100010
#define INF 1<<28
using namespace std;
bool cnt[MAX_N];
int edge,V;
int u,v;
int main()
{
while(scanf("%d%d",&u,&v) != EOF) {
if (u == -1 && v == -1) break;
if (u != 0 && v != 0) {
memset(cnt,0,sizeof cnt);
V = 0;
edge = 0;
V+=2;
cnt[u] = cnt[v] = true;
edge++;
while (scanf("%d%d",&u,&v) != EOF && (u + v)) {
if (!cnt[u]){
V++;
cnt[u] = true;
}
if (!cnt[v]){
cnt[v]= true;
V++;
}
edge++;
}
if (edge == V - 1){
printf("Yes\n");
} else {
printf("No\n");
}
} else {
printf("Yes\n");
}
}
return 0;
}