22300_AustralianVoting

2022-5-16 18:21| 发布者: Hocassian| 查看: 21| 评论: 0|原作者: 肇庆学院ACM合集

摘要:
C:\Users\Administrator\Downloads\2019-10-12-10-14-5-89506303248500-Problem List-采集的数据-后羿采集器.html

Pro.ID

22300

Title

Australian Voting

Title链接

http://10.20.2.8/oj/exercise/problem?problem_id=22300

AC

1

Submit

3

Ratio

33.33%

时间&空间限制

  • Time Limit: 1200/400 MS (Java/Others)     Memory Limit: 131072/65536 K (Java/Others)
  • 描述

    Australian ballots require that the voter rank the candidates in order of choice. Initially only the first choices are counted and if one candidate receives more than 50% of the vote, that candidate is elected. If no candidate receives more than 50%, all candidates tied for the lowest number of votes are eliminated. Ballots ranking these candidates first are recounted in favour of their highest ranked candidate who has not been eliminated. This process continues [that is, the lowest candidate is eliminated and each ballot is counted in favour of its ranked non-eliminated candidate] until one candidate receives more than 50% of the vote or until all candidates are tied.

    输入

    The first line of input is an integer n <= 20 indicating the number of candidates. The next n lines consist of the names of the candidates in order. Names may be up to 80 characters in length and may contain any printable characters. Up to 1000 lines follow; each contains the contents of a ballot. That is, each contains the numbers from 1 to n in some order. The first number indicates the candidate of first choice; the second number indicates candidate of second choice, and so on.

    输出

    Description
    Australian ballots require that the voter rank the candidates in order of choice. Initially only the first choices are counted and if one candidate receives more than 50% of the vote, that candidate is elected. If no candidate receives more than 50%, all candidates tied for the lowest number of votes are eliminated. Ballots ranking these candidates first are recounted in favour of their highest ranked candidate who has not been eliminated. This process continues [that is, the lowest candidate is eliminated and each ballot is counted in favour of its ranked non-eliminated candidate] until one candidate receives more than 50% of the vote or until all candidates are tied.
    Input
    The first line of input is an integer n <= 20 indicating the number of candidates. The next n lines consist of the names of the candidates in order. Names may be up to 80 characters in length and may contain any printable characters. Up to 1000 lines follow; each contains the contents of a ballot. That is, each contains the numbers from 1 to n in some order. The first number indicates the candidate of first choice; the second number indicates candidate of second choice, and so on.
    Output
    The Output consists of either a single line containing the name of the winner or several lines containing the names of the candidates who tied.
    Sample Input
    3
    John Doe
    Jane Smith
    Sirhan Sirhan
    1 2 3
    2 1 3
    2 3 1
    1 2 3
    3 1 2
    Sample Output
    John Doe
    Source

    样例输入

    3
    John Doe
    Jane Smith
    Sirhan Sirhan
    1 2 3
    2 1 3
    2 3 1
    1 2 3
    3 1 2

    样例输出

    John Doe

    作者


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部