输出字符串人名是否是唯一的,怎么利用C语言的程序的代码的编写的思路实现的?

Problem Description
Dear Contestant,

I'm going to have a party at my villa at Hali-Bula to celebrate my retirement from BCM. I wish I could invite all my co-workers, but imagine how an employee can enjoy a party when he finds his boss among the guests! So, I decide not to invite both an employee and his/her boss. The organizational hierarchy at BCM is such that nobody has more than one boss, and there is one and only one employee with no boss at all (the Big Boss)! Can I ask you to please write a program to determine the maximum number of guests so that no employee is invited when his/her boss is invited too? I've attached the list of employees and the organizational hierarchy of BCM.

Best,
--Brian Bennett

P.S. I would be very grateful if your program can indicate whether the list of people is uniquely determined if I choose to invite the maximum number of guests with that condition.

Input
The input consists of multiple test cases. Each test case is started with a line containing an integer n (1 ≤ n ≤ 200), the number of BCM employees. The next line contains the name of the Big Boss only. Each of the following n-1 lines contains the name of an employee together with the name of his/her boss. All names are strings of at least one and at most 100 letters and are separated by blanks. The last line of each test case contains a single 0.

Output
For each test case, write a single line containing a number indicating the maximum number of guests that can be invited according to the required condition, and a word Yes or No, depending on whether the list of guests is unique in that case.

Sample Input
6
Jason
Jack Jason
Joe Jack
Jill Jason
John Jack
Jim Jill
2
Ming
Cho Ming
0

Sample Output
4 Yes
1 No

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问

相似问题

4
怎么javascrpt语言实现将一个字符串转换为多个字符串构成的数组并且判断每个字符串的数组?
2
字符串怎么在jacvscropt语言里实现字符串的判断
3
javascpt语言怎么对字符串的类型用类型判断?怎么判断字符串属于的类型是什么?
1
请问ASCII控制字符的问题?c语言字符串的问题
4
C#怎么判断字符串里是否有路径
2
如何用C语言字符串相关知识编写这个程序
1
C语言字符串的排序问题如何解决?
1
C语言新手问题scanf函数将字符串指针用%c的格式输出结果是什么?
1
C语言计算实现,字符串的编码值小于等于给定的值则输出yes,否则输出no
0
输入一个字符串,判断其是否是C的合法标识符,运用C语言编程处理的方式
1
C语言求助:输入一个字符串,将其中的字母字符输入一个链表,将其中的数字字符输入另一个链表。
0
原代码的格式化的字符串的对齐,如何利用C语言的程序设计的算法的思路来实现
1
(C语言)输入一个有20个以上字符的字符串,分别统计字符串中字符a和s(只限于小写)的个数,并输出结果。
0
关于最长的二进制子字符串的算法问题,怎么利用C语言的程序的设计的方式来实现
1
用C语言如何解决:对于输入的每个字符串,查找其中的最大字母,在该字母后面插入字符串
0
关键字的字符串的搜索的运用,怎么利用C语言的程序的编写的方法去实现的呢?
0
字符串的搜索的一个算法的问题,怎么利用C语言的程序的设计的办法去实现
0
根据存储空间判断这个字符串是否是安全的,运用C语言的程序实现的过程如何做?
0
姓名字符串的条件的排序的算法的问题,怎么利用C语言的程序的编写的思想实现?
0
阶梯式的字符串输出的问题,如何采用C语言程序设计思维的方式实现的呢?