HDU-2094 Produce Champion

Source: Internet
Author: User
Question: There are a group of people, playing table tennis games, 22 catch to kill, every two people to play a maximum of a game.
The rules of the game are as follows:
If a defeated B,b and defeated C, and A and C did not play, then it is decided that a must be able to defeat C.
If a defeated B,b and defeated C, and C defeated A, then a, B, C Three will not be the champion.

According to this rule, there is no need to cycle a contest, perhaps to determine the championship. Your task is to face a group of contestants, after a number of killings, to determine whether it has actually produced a championship.

Examples:

3 Alice Bob Smith John Alice Smith 5 a C c D d e b e a D 0 analysis: The second column is the loser ... Directly find the person who has not lost a few, if it is the first to produce a champion ... Other bloggers have some doubts about the problem ... Say: A beats b,b to defeat C; At the same time: D beats E, E defeats F, F beats D. The latter is a cycle, it is impossible to determine that a defeated D, E, f ... I think there's some truth in what this great God says ... I didn't think so much ... So let's do it first ... Level Limited ...

#include <iostream>
#include <cstdio>
#include <string>
#include <set>
using namespace std;
int main () {
	int q;
	Set<string> all;
	Set<string> lose;
	while (scanf ("%d", &q)!=eof && q) {
		string A, B;
		while (q--) {
			cin>>a>>b;
			All.insert (a);
			All.insert (b);
			Lose.insert (b);
		}
		if (All.size ()-lose.size () = = 1) cout<< "Yes" <<endl;
		else cout<< "No" <<endl;
		All.clear ();
		Lose.clear ();
	}
	return 0;
}


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.