当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

2643:Election

题目描述
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.
输入解释
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 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.
输入样例
3
Marilyn Manson
Rhinoceros
Jane Doe
Family Coalition
John Smith
independent
6
John Smith
Marilyn Manson
Marilyn Manson
Jane Doe
John Smith
Marilyn Manson
输出样例
Rhinoceros

该题目是Virtual Judge题目,来自 北京大学POJ

源链接: POJ-2643

最后修改于 2020-10-29T06:38:04+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
1000 65536