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

建议使用的浏览器:

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

1585:Helping Florida

题目描述
While Florida's difficulties electing presidents are well known, a lesser known problem is electing committee chairs within the state's House of Delegates. The process used is a runoff election,where each committee member submits a ballot with a ranked list of other members for the position of chair. Unfortunately, those responsible for tabulating the votes keep losing track of which ballots still have countable votes, and so no one trusts the results.
Each committee member submits a ballot. Each ballot contains a ranked list of votes. Tabulating the votes proceeds in rounds. For the first round, the first vote on each ballot is counted. If any candidate has more than half of the votes, they win.
After each round, the candidate receiving the fewest votes (or candidates, in the case of a tie for fewest votes) is eliminated. Votes are then re-tabulated with each ballot's highest vote for a remaining candidate being counted. If all of the candidates voted for on a ballot are eliminated,then that ballot is considered "non-viable," and it is no longer counted toward the total number of ballots when calculating majority.
The process is repeated until you have a single winner, or a tie between the remaining candidates.The rules of the election guarantee you will have a tie or a winner.
输入解释
For each dataset:
Line 1 < candidates > < ballots >
The number of candidates receiving votes
The number of ballots, b
b Lines One line per ballot. For each ballot, the names of the candidates are listed in order of preference. A candidate name is a string with no whitespace in it. A ballot may not contain votes for all candidates. No candidate will be repeated on a single ballot.
After the last dataset, a line of
0 0
will indicate the end of the input.
输出解释
For each dataset a single line is output:
For a winner:
< candidate > won
For a tie:
it is a tie between < candidate > and < candidate > [ and < candidate > [...]]
Each candidate name is separated by "and". They may be printed in increasing order.
输入样例
3 9
Buchanan Bush
Buchanan Bush
Buchanan Gore
Gore Bush
Gore Bush
Gore Bush
Gore Bush
Bush Buchanan
Bush Buchanan
0 0
输出样例
Buchanan won

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

题目来源 Mid-Atlantic 2003

源链接: POJ-1585

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

共提交 0

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