#Lutece0727. Condorcet Winners
Condorcet Winners
Migrated from Lutece 727 Condorcet Winners
All parts of this problem, including description, images, samples, data and checker, might be broken. If you find bugs in this problem, please contact the admins.
Description
A Condorcet winner of an election is a candidate who would beat any of the other candidates in a one-on-one contest. Determining a Condorcet winner can only be done when voters specify a ballot listing all of the candidates in their order of preference (we will call such a ballot a preference list). For example, assume we have candidates - , and - and three voters whose preference lists are , , . Here, is the Condorcet winner, beating in of the three ballots (ballots and ) and beating in of the three ballots ( and ).
The Condorcet voting system looks for the Condorcet winner and declares that person the winner of the election. Note that if we were only considering first place votes in the example above (as we do in most elections in the US and Canada), then there would be a tie for first place. There can be at most only one Condorcet winner, but there is one small drawback in the Condorcet system | it is possible that there may be no Condorcet winner.
Input
Input for each test case will start with a single line containing two positive integers , where indicates the number of ballots and indicates the number of candidates. Candidates are considered numbered . Following this first line will be lines containing values each. Each of these lines represents one ballot and will contain the values in some permuted order. Values of and will lie in the ranges and , respectively, and the line 0 0
will follow the last test case.
Output
For each test case output a single line containing either the candidate number of the Condorcet winner,or the phrase No Condorcet winner
using the format given.
Samples
3 3
0 1 2
1 0 2
2 1 0
3 3
0 1 2
1 2 0
2 0 1
0 0
Case 1: 1
Case 2: No Condorcet winner
Resources
2011 East Central Regional Contest