When the old year is leaving and the New Year is coming, people are always looking back over the past while looking forward to the future.
Input The input contains data for several test cases.
Output For each test case output "Yes" means the match table is correct, or "No" otherwise.
Sample Input 2 1-2 4 1-2 3-4 1-3 2-4 1-4 2-3 4 1-3 2-4 1-2 3-4 1-4 2-3 4 1-2 3-2 1-3 2-4 1-4 2-3
Sample Output Yes Yes Yes No
|
#include<iostream>
#include<cstring>
#include <cstdio>
using namespace std;
bool vis[2020];
int main()
{
//freopen("C:\\Users\\23535\\Desktop\\in.txt","r",stdin); //输入重定向,输入数据将从D盘根目录下的in.txt文件中读取
// freopen("C:\\Users\\23535\\Desktop\\out.txt","w",stdout); //输出重定向,输出数据将保存在D盘根目录下的out.txt文件中
int n;
int a,b;
while(cin>>n)
{
int dui[20020]={0};
int flag=1;
for(int i=1;i<=n-1;i++)
{
memset(vis,0,sizeof(vis));
for(int j=1;j<=n/2;j++ )
{
scanf("%d-%d",&a,&b);
if(vis[a]||vis[a]){
flag=0;
}
vis[a]=1;
vis[b]=1;
dui[a]++;
dui[b]++;
}
}
if(flag){
for(int i=1;i<=n;i++)
{
if(dui[i]!=n-1)
{
flag=0;
break;
}
}
}
//cout<<flag;
if(flag==1)
cout<<"Yes"<<endl;
else
cout<<"No"<<endl;
/* for(int i=0;i<10;i++)
{
cout<<dui[i];
}
*/
}
//fclose(stdin);//关闭重定向输入
//fclose(stdout);//关闭重定向输出
return 0;
}