ExpediaOA #2
Song Preference Ranking
Estimated MediumJudge-ready
Topics (AI-labelled)SimulationIn-place Arrays
One song beats another if more than half of the users prefer the former, or exactly half do and the former has the smaller id. A song's popularity is the number of songs it beats.
Input
The first line contains n m (1≤n,m≤200), followed by n lines, each a permutation of 0..m−1 listing one user's songs from most to least preferred.
Output
Output the song ids sorted by the number of songs beaten in descending order, with the smaller id first on ties, separated by spaces.
Example 1
Input:
3 3
0 1 2
0 2 1
1 2 0
Output:
0 1 2
Example 2
Input:
2 2
0 1
1 0
Output:
0 1
Example 3
Input:
1 1
0
Output:
0
Editorial
Loading solution…