URAL 1728. Curse on team.gov (STL set)

Source: Internet
Author: User

Title Link: http://acm.timus.ru/problem.aspx?space=1&num=1728


1728. Curse on Team.govtime limit:0.5 second
Memory limit:64 MB
All the names-problem is fictitious; the coincidences is accidental.Long ago There was the Alarm team at the Ural state University. Its members Lyosha, Vadik, and Misha enjoyed going to programming contests instead of studying. In this composition, the team participated in contests for a whole year. But once, after a conflict at a contest in Kazan, Lyosha and Vadik expelled Misha from the team and changed their name to Te Am.gov. After that, Lyosha and Vadik decided the third member of the team would is Sasha. But he didn ' t come to the Ural SU Championship and said that he was very busy. Lyosha and Vadik had to participate on that contest without the third programmer. However, Sasha was wasn't expelled from the team and took part in a subregional contest, which they lost. After this, the team "Lyosha, Vadik, Sasha" suddenly turned into the team "Vanya, Lyosha, Vadik" and went to the regional Contest, which they also lost. It is rumored this team.gov is cursed. After Alarm's break-up, the team composition is different at each contest. An ICPC subregional conTest is approaching, and the organizing committee obliged Lyosha and Vadik to find the third member of the team. Lyosha and Vadik compiled a list of candidates and calculated the rating of each candidate according to a secret formula. The power of the team is equal to the sum of the ratings's members. Lyosha and Vadik want their team to be as powerful as possible. But the team is cursed ... As the Fates decree, if the team composition repeats a composition that once participated in some contest, Lyosha won ' t be Able to come to the contest (and the power of the team would decrease by his rating). Even in this case, if this team composition (without Lyosha) participated in some contest earlier, Team.gov would suddenly Be disqualified during the practice session and won ' t take part in the contest. Help the permanent members of Team.gov choose the third member so that the Team would be as powerful as possible in the Sub Regional contest. Inputthe First line contains the number of Contests&nbsP NTeam.gov participated in (1≤ N≤100). Each of the following NLines describes one contest. The line starts with the number of the team's members that participated in the contest (an integer in the range from one T O three). This was followed by the space-separated list of last names of these members given in the alphabetical order. The names is different nonempty strings consisting of lowercase and uppercase 中文 letters. The length of each name was at most 50. Lyosha ' s last name was Efremov and Vadik's last name was Kantorov. It is guaranteed that Vadik are present in all the compositions, and Lyosha are present in all the compositions consisting O F three people. All the given compositions is different. The following line contains space-separated integers RE and rK (1≤ rE, rK ≤666) . They is Lyosha ' s and Vadik ' s ratings, respectively. The following line contains the number mOf candidates who want to enter the team (1≤ m≤100). Each of the following mLines contains the last name and the rating of a candidate separated with a space. All the ratings is integers in the range from 1 to 666. All of the last names is different. The list of candidates contains neither Lyosha nor vadik.outputif, for any choice of the third member, Team.gov would be di squalified, output the only line "Fail". Otherwise, in the first line output "Win" and the the second line output the last name of the candidate who would become the Third member of Team.gov. If there is several possible answers, output any of them. Samples
input Output
63 Efremov Kantorov Rubinchik2 efremov Kantorov3 efremov Kantorov Kokovin3 Burmistrov Efremov Kantorov 3 Efremov Kantorov Pervukhin2 Kantorov Pervukhin100 106Fominykh 200Komarov 34Pervukhin 250Golubev 23Soboleva 50Gein 50 
winfominykh 
Efremov fominykh Kantorov2 fominykh Kantorov99 6661Fominykh 100
Fail


The code is as follows:

#include <cstdio> #include <cstring> #include <string> #include <set> #include <iostream>    #include <algorithm>using namespace std;set<string>m2, M3;int main () {int n, m;    string S;            while (~SCANF ("%d", &n)) {for (int i = 0; i < n; i++) {cin >> m;                for (int j = 0; J < m; J + +) {cin >> S;                        if (s! = "Kantorov" && s! = "Efremov") {if (M = = 2) {                    M2.insert (s);                    } else if (m = = 3) {M3.insert (s);        }}}} int pe, PK;        int q, Power;        String QQ;        CIN >> PE >> PK;        CIN >> Q;        String ans;        int maxx = 0; for (int i = 0; i < Q; i++) {cin >> QQ >> Power;                if (M2.count (QQ) ==0 && pk+power > Maxx) {ans = QQ;            Maxx = Pk+power;                } if (M3.count (QQ) ==0 && pk+power+pe > Maxx) {ans = QQ;            Maxx = Pk+power+pe;        }} if (Maxx = = 0) {cout<< "Fail" <<endl;            } else {cout<< "Win" <<endl;        cout<<ans<<endl; }} return 0;}


URAL 1728. Curse on team.gov (STL set)

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.