URAL 1728. Curse on Team.GOV(STL set)

题目链接:http://acm.timus.ru/problem.aspx?space=1&num=1728

1728. Curse on Team.GOV

Time limit: 0.5 second

Memory limit: 64 MB

All the names in this problem are fictitious; the coincidences are 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 its name to Team.GOV.

After that, Lyosha and Vadik decided that the third member of the team would be Sasha. But he didn‘t come to the Ural SU Championship and said that he was very busy. Lyosha and Vadik had to participate
in that contest without the third programmer. However, Sasha was not expelled from the team and took part in a subregional contest, which they lost. After that, 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 that 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 of its 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 will decrease by his rating). Even in this case, if this team composition (without Lyosha) participated in some contest earlier,
Team.GOV will 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 will be as powerful as possible in the subregional contest.

Input

The first line contains the number of contests n Team.GOV participated in (1 ≤ n ≤ 100). Each of the following n lines 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 to three). This number is followed by the space-separated list of last names of these members given in the alphabetical order. The names are different nonempty strings
consisting of lowercase and uppercase English letters. The length of each name is at most 50. Lyosha‘s last name is Efremov and Vadik‘s last name is Kantorov. It is guaranteed that Vadik is present in all the compositions, and Lyosha is present in all the
compositions consisting of three people. All the given compositions are different.

The following line contains space-separated integers re and rk (1
≤ rerk ≤ 666). They are Lyosha‘s and Vadik‘s ratings, respectively. The
following line contains the number m of candidates who want to enter the team (1 ≤ m ≤ 100). Each of the following m lines contains the last name and the rating of a candidate separated with a space. All the ratings are integers
in the range from 1 to 666. All the last names are different. The list of candidates contains neither Lyosha nor Vadik.

Output

If, for any choice of the third member, Team.GOV will be disqualified, output the only line “Fail”. Otherwise, in the first line output “Win” and in the second line output the last name of the candidate
who will become the third member of Team.GOV. If there are several possible answers, output any of them.

Samples

input output
6
3 Efremov Kantorov Rubinchik
2 Efremov Kantorov
3 Efremov Kantorov Kokovin
3 Burmistrov Efremov Kantorov
3 Efremov Kantorov Pervukhin
2 Kantorov Pervukhin
100 10
6
Fominykh 200
Komarov 34
Pervukhin 250
Golubev 23
Soboleva 50
Gein 50
Win
Fominykh
2
3 Efremov Fominykh Kantorov
2 Fominykh Kantorov
99 666
1
Fominykh 100
Fail

代码如下:

#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;
}
时间: 2024-07-29 14:06:55

URAL 1728. Curse on Team.GOV(STL set)的相关文章

Ural 1613 For Fans of Statistics(vector应用)

题目: For Fans of Statistics Time Limit:1000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64 Description Have you ever thought about how many people are transported by trams every year in a city with a ten-million population where one in th

URAL 1727. Znaika&#39;s Magic Numbers(数学 vector)

题目链接:http://acm.timus.ru/problem.aspx?space=1&num=1727 1727. Znaika's Magic Numbers Time limit: 0.5 second Memory limit: 64 MB Znaika has many interests. For example, now he is investigating the properties of number sets. Znaika writes down some set

UVA 10474:Where is the Marble?(STL初步)

 Where is the Marble?  Raju and Meena love to play with Marbles. They have got a lot of marbles with numbers written on them. At the beginning, Raju would place the marbles one after another in ascending order of the numbers written on them. Then Mee

URAL 1707. Hypnotoad&amp;#39;s Secret(树阵)

URAL 1707. Hypnotoad's Secret space=1&num=1707" target="_blank" style="">题目链接 题意:这题设置的恶心不能多说.构造点和矩形.大概就是问每一个矩形里面是否包括点 思路:树状数组.把点排序,按y轴,在按x轴.在按询问,这样每次遇到一个点就在对应的扫描线上加.遇到查询就询问出左边到这个点位置的,就能预处理出每一个点左下角包括的点的个数,然后每一个矩形再利用容斥原理去搞一下就

P1540 机器翻译(STL 链表)

题目背景 小晨的电脑上安装了一个机器翻译软件,他经常用这个软件来翻译英语文章. 题目描述 这个翻译软件的原理很简单,它只是从头到尾,依次将每个英文单词用对应的中文含义来替换.对于每个英文单词,软件会先在内存中查找这个单词的中文含义,如果内存中有,软件就会用它进行翻译:如果内存中没有,软件就会在外存中的词典内查找,查出单词的中文含义然后翻译,并将这个单词和译义放入内存,以备后续的查找和翻译. 假设内存中有M个单元,每单元能存放一个单词和译义.每当软件将一个新单词存入内存前,如果当前内存中已存入的单

URAL 1748. The Most Complex Number(反素数)

题目链接 题意 :给你一个n,让你找出小于等于n的数中因子个数最多的那个数,并且输出因子个数,如果有多个答案,输出数最小的那个 思路 : 官方题解 : (1)此题最容易想到的是穷举,但是肯定超时. (2)我们可以知道,计算约数的个数和质因数分解有着很大的联系: 若Q的质因数分解为:Q=p1^k1*p2^k2*…*pm^km(p1…pm为素数,k1…km≥1),则Q有(k1+1)(k2+1)…(km+1)个约数.但是质因数分解的时间复杂度很高,所以也会超时. (3)通过以上的公式,我们可以“突发奇

CodeForces 993B Open Communication(STL 模拟)

https://codeforces.com/problemset/problem/993/b 题意: 现在有两个人,每个人手中有两个数,其中两个人手中的数有一个是相同的(另一个不一样), 现在第一个人会给你n对数,保证其中一对就是他手上的两个数,第二个人会给你m对数,保证其中一对是他手上的两个数. 现在你作为一个旁观者,如果能分辨出相同的数,则输出它,如果你知道手上有牌的人知道相同的数,那么输出0,其余则输出-1. 思路: 其实就是n对和m对数中,找共享数字,直接看样例吧: 在第一示例中,第一

UVA - 540 Team Queue(STL,队列 )

Team Queue Time Limit: 3000MS   Memory Limit: Unknown   64bit IO Format: %lld & %llu Submit Status Description Queues and Priority Queues are data structures which are known to most computer scientists. The Team Queue, however, is not so well known,

URAL 1563. Bayan (STL map)

1563. Bayan Time limit: 1.0 second Memory limit: 64 MB As everybody knows, there are a lot of stores in skyscrapers, it's the favourite place of glamorous girls. Blonde Cindy loves only one thing - the shopping. Today is one of the best days, she's g