HDU 2094 topology sequencing

Source: Internet
Author: User

Produce Champions

Time limit:1000/1000 MS (java/others) Memory limit:32768/32768 K (java/others) total submission (s): 12031 Accepted Submission (s): 5583

Problem description A group of people, playing table tennis game, 22 catch to kill, every two people play a maximum of a game. The rules of the game are as follows: If a beats b,b and beats C, and A and C do not play, then it is assumed that a must 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. Input inputs contain a number of contestants, each of which starts with an integer n (n<1000) followed by N against the competitor, and the result is a pair of player names (one space between them), the former defeating the latter. If n is 0, it indicates the end of the input.
Output for each player group, if you determine that a winner is generated, export "Yes" in one line, otherwise output "No" in a row. Sample Input3 Alice Bob Smith John Alice Smith 5 a C c D d e b e A D 0 sample Outputyes No today just learning topological sequencing the main thing is that the search for zero points is especially This topic input storage is a difficult point I have been using the map is actually a method only a zero in the points can produce CHAMPIONS!!!! Start blogging again!!
1#include <bits/stdc++.h>2 using namespacestd;3map<string,int>inch;4map<string,map<string,int> >MP;5map<int,string>dis;6map<string,int>PiS;7queue<string>Q;8 intMain ()9 {Ten     intN; One     intCoun; A      while(SCANF ("%d", &n)! =EOF) -     { -         if(n==0) the              Break; -         inch. Clear (); Mp.clear (); - dis.clear ();p is.clear (); -coun=1; +         stringstr1,str2; -          for(intI=1; i<=n; i++) +         { ACin>>str1>>str2; at             if(pis[str1]==0) -             { -pis[str1]=1; -dis[coun++]=str1; -             } -             if(pis[str2]==0) in             { -pis[str2]=1; todis[coun++]=str2; +             } -             if(mp[str1][str2]==0) the             { *mp[str1][str2]=1; $                 inch[str2]++;Panax Notoginseng             } -         } the         intflag=0; +          for(intI=1; i<coun;i++) A         { the             if(inch[dis[i]]==0) +             { -flag++; $ Q.push (Dis[i]); $             } -         } -         if(flag==1) theprintf"yes\n"); -         ElseWuyiprintf"no\n"); the } - return 0; Wu}

HDU 2094 topology sequencing

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.