题目链接:

space=1&num=1728" target="_blank">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;
}

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

  1. random_shuffle (stl算法)打乱顺序 - 飞不会的日志 - 网易博客

    random_shuffle (stl算法)打乱顺序 - 飞不会的日志 - 网易博客 random_shuffle (stl算法)打乱顺序 2012-03-31 10:39:11|  分类: 算法 | ...

  2. P1540 机器翻译(STL 链表)

    题目背景 小晨的电脑上安装了一个机器翻译软件,他经常用这个软件来翻译英语文章. 题目描述 这个翻译软件的原理很简单,它只是从头到尾,依次将每个英文单词用对应的中文含义来替换.对于每个英文单词,软件会先 ...

  3. 【UVA - 540】Team Queue (map,队列)

    Team Queue Descriptions: Queues and Priority Queues are data structures which are known to most comp ...

  4. 堆模板(STL版)

    题目描述 如题,初始小根堆为空,我们需要支持以下3种操作: 操作1: 1 x 表示将x插入到堆中 操作2: 2 输出该小根堆内的最小数 操作3: 3 删除该小根堆内的最小数 输入输出格式 输入格式: ...

  5. 数据结构知识总结(STL整理)

    重要知识点 1.基础知识 #include<bits/stdc++.h> //万能头文件 #include< algorithm > //包含sort函数 运用sort实现多关 ...

  6. ACM-ICPC 2018 徐州赛区网络预赛 F Features Track(STL模拟)

    https://nanti.jisuanke.com/t/31458 题意 有N个帧,每帧有K个动作特征,每个特征用一个向量表示(x,y).两个特征相同当且仅当他们在不同的帧中出现且向量的两个分量分别 ...

  7. PAT 1087 有多少不同的值(20)(STL—set)

    1087 有多少不同的值(20 分) 当自然数 n 依次取 1.2.3.--.N 时,算式 ⌊n/2⌋+⌊n/3⌋+⌊n/5⌋ 有多少个不同的值?(注:⌊x⌋ 为取整函数,表示不超过 x 的最大自然数 ...

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

    题目链接 题意 :给你一个n,让你找出小于等于n的数中因子个数最多的那个数,并且输出因子个数,如果有多个答案,输出数最小的那个 思路 : 官方题解 : (1)此题最容易想到的是穷举,但是肯定超时. ( ...

  9. CodeForces 993B Open Communication(STL 模拟)

    https://codeforces.com/problemset/problem/993/b 这题不难,暴力就能过,主要是题意太难懂了 题意: 现在有两个人,每个人手中有一对数,第一个人手中的数是n ...

随机推荐

  1. php session 管理

    function do_login(){ //获取用户名和密码信息,和数据库中比对 echo 111111111; dump($_POST); dump($_SESSION); echo 222222 ...

  2. zip非暴力破解

    大家最熟悉的zip破解方式应该是暴力破解,暴力破解有很大局限性,如果密码很长很复杂你很可能一辈子都破解不出来.由于今天要破解自己以前加密过的zip文件,我设的密码习惯性长而复杂,果断放弃暴力破解,在网 ...

  3. 代码写解压zip文件

    最近项目中服务器方返回了zip文件类型的文件,在网上搜了好多资料做成一个Demo,这里用来详解一下. ZipArchive类来源于网络.还望多多交流. 1.首先添加libz.dylib框架 2.前往h ...

  4. CentOS6.4 编译安装Python 3.3.2 - CRPER木木

    基础环境: CentOS6.4(预装GCC,或者联网YUM---GCC编译写进这里太臃肿,找机会另外写一篇) Python 3.3.2     下载链接: http://www.python.org/ ...

  5. jquery中怎么删除<ul>中的整个<li>包括节点

    .$('ul li').remove(); .$('ul li').each(function(){ $(this).remove(); }); .$("ul").find(&qu ...

  6. 60s 经济学探奇

    理解经济学 什么是经济学.对于学习金融的同学,一定会给你搬出一大堆定义.例证.学派.说经济学是一门研究研究价值的生产.流通.分配.消费的规律的理论. 非常高大上的感觉,可是对于我这样没有什么金融学理论 ...

  7. Lambda高手之路第三部分

    转http://www.cnblogs.com/lazycoding/archive/2013/01/06/2847587.html 背后的秘密-MSIL 通过著名的LINQPad,我们可以更深入的查 ...

  8. POJ 3040 Allowance 贪心

    这题目的贪心思路还是有一点细节问题的. 还没有证明,据说是因为题目给的条件是每个价格是比它小的价格的倍数才能这么贪心的. 思路如下: 假设要给奶牛的钱为C 1)从大面值到小面值一次拿钱,能拿多少拿多少 ...

  9. DataGirdView 设置单元格居中

    设置标题行居中: dgvShow.ColumnHeadersDefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter ...

  10. 1-5html文件基本结构

    认识html文件基本结构 1)这一节中我们来学习html文件的结构:一个HTML文件是有自己固定的结构的. <html> <head>...</head> < ...