Election
Time Limit: 1000MS   Memory Limit: 65536K
Total Submissions: 3558   Accepted: 1692

Description

Canada has a multi-party system of government. Each candidate is generally associated with a party, and the party whose candidates win the most ridings generally forms the government. Some candidates run as independents, meaning they are not associated with any party. Your job is to count the votes for a particular riding and to determine the party with which the winning candidate is associated.

Input

The first line of input contains a positive integer n satisfying 2 <= n <= 20, the number of candidates in the riding. n pairs of lines follow: the first line in each pair is the name of the candidate, up to 80 characters; the second line is the name of the party, up to 80 characters, or the word "independent" if the candidate has no party. No candidate name is repeated and no party name is repeated in the input. No lines contain leading or trailing blanks. 
The next line contains a positive integer m <= 10000, and is followed by m lines each indicating the name of a candidate for which a ballot is cast. Any names not in the list of candidates should be ignored. 

Output

Output consists of a single line containing one of:

  • The name of the party with whom the winning candidate is associated, if there is a winning candidate and that candidate is associated with a party.
  • The word "independent" if there is a winning candidate and that candidate is not associated with a party.
  • The word "tie" if there is no winner; that is, if no candidate receives more votes than every other candidate.

Sample Input

3
Marilyn Manson
Rhinoceros
Jane Doe
Family Coalition
John Smith
independent
6
John Smith
Marilyn Manson
Marilyn Manson
Jane Doe
John Smith
Marilyn Manson

Sample Output

Rhinoceros
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<string>
#include<algorithm>
#include<math.h>
#include<iomanip>
#include<queue>
#include<map>
using namespace std; int main()
{
int Max = -;
bool flag = false;
map<string, string> ss;
map<string, int> st;
char Name[], Party[];
int n;
cin>>n;
getchar();
for (int i = ; i < n; i++)
{
gets(Name);
gets(Party);
ss[Name] = Party;
}
cin>>n;
getchar();
string result;
for (int i = ; i< n; i++)
{
gets(Name);
if (ss[Name] == "")
{
continue;
}
int nCount = ++st[Name];
if (nCount > Max)
{
flag = true;
result = Name;
Max = nCount;
}
else
{
if (nCount == Max)
{
flag = false;
}
}
}
if (flag)
{
cout<<ss[result]<<endl;
}
else
{
cout<<"tie"<<endl;
}
return ;
}

POJ 2643 Election的更多相关文章

  1. POJ 2643 Election map

    POJ 2643 Election 第一次写博客,想通过写博客记录自己的ACM历程,也想解释下英文题目,写些自己的理解.也可以让自己以后找题目更加方便点嘛.ElectionTime Limit: 10 ...

  2. POJ 2643

    #include<iostream> #include<stdio.h> #include<string> #include<algorithm> #d ...

  3. POJ 3664 Election Time 题解

    这道题网上非常多人都会说easy,水题之类的话,只是我看了下说这种话的人的程序,能够说他们的程序都不及格! 为什么呢?由于他们的程序都是使用简单的二次排序水过(大概你能搜索到的多是这种程序).那样自然 ...

  4. POJ 3905 Perfect Election(2-sat)

    POJ 3905 Perfect Election id=3905" target="_blank" style="">题目链接 思路:非常裸的 ...

  5. POJ 3905 Perfect Election (2-Sat)

    Perfect Election Time Limit: 5000MS   Memory Limit: 65536K Total Submissions: 438   Accepted: 223 De ...

  6. POJ 3905 Perfect Election

    2-SAT 裸题,搞之 #include<cstdio> #include<cstring> #include<cmath> #include<stack&g ...

  7. POJ 3905 Perfect Election (2-SAT 判断可行)

    题意:有N个人参加选举,有M个条件,每个条件给出:i和j竞选与否会只要满足二者中的一项即可.问有没有方案使M个条件都满足. 分析:读懂题目即可发现是2-SAT的问题.因为只要每个条件中满足2个中的一个 ...

  8. POJ 2528 Mayor's posters

    Mayor's posters Time Limit:1000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u Sub ...

  9. POJ 1625 Censored!(AC自动机+DP+高精度)

    Censored! Time Limit: 5000MS   Memory Limit: 10000K Total Submissions: 6956   Accepted: 1887 Descrip ...

随机推荐

  1. Install your Application into RaspberryPi2 and automatically start up

    如何安装和卸载应用程序到RaspberryPi2? 如何配置应用程序在RaspberryPi2开机后自动启动? How to install your app into RaspberryPi2? H ...

  2. UIButton 左对齐 省略号最右边

    //左对齐 [_btn setContentHorizontalAlignment:UIControlContentHorizontalAlignmentLeft]; //省略号靠右侧 _btn.ti ...

  3. 怎样将英文版的Eclipse转为中文版的?

    =====>1.打开eclipse储存文件夹 =====>2.在eclipse文件中找到dropins文件 =====>3.把已经下载好的eclipse汉化包复制到dropins中 ...

  4. iTOP-IMX6UL 实战项目:ssh 服务器移植到 arm 开发板

    实验环境:迅为提供的Ubuntu12.04.2 以及虚拟机 编译器:arm-2009q3 编译器 开发板系统:QT系统   开发板使用手册中给Windows 系统安装了 ssh 客户端,给 Ubunt ...

  5. 在vue组件库中不能使用v-for

    没事的,有点时候编辑器报错,但运行不一定出错, 在vue组件中注意template标签

  6. 汇编segment

    一个正常的应用程序被由若干个 segment组成. 定义 segment: SECTION .段名 SECTION 也可以小写 如: 定义数据段: section .data   定义代码段: sec ...

  7. jsc 解码窥探

    先使用 JS_DecodeScript反编译jsc  得到AST树 AST树词法解析 http://esprima.org/ AST还原成源码: npm install escodegen AST树遍 ...

  8. django 2.0 + pycharm2017 出现的问题

    在创建完成app之后,在models文件里创建两个类:BlogType , Blog, 创建超级用户,注册admin,在登陆admin之后发现,发现 BlogType , Blog,并没有导入到adm ...

  9. CPP-基础:C++的new int()与new int[]

    编写一个List类: class List { int length; //列表长度 int* lpInt; //列表指针 List(int size); ~List(); } List::List( ...

  10. 【Codeforces #228】Solutions

    http://codeforces.com/contest/389 重新把号刷到Div 1 准备ACM?(我这么菜还是玩玩算了……) 官方题解出的很快 Div2 A: 怎么做都行……随便找俩数减就可以 ...