cswork / OA打开练习工作台

ExpediaOA #2

Song Preference Ranking

估计中等可在线判题

考点(AI 标注)模拟/实现原地数组

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.

输入格式

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 the song ids sorted by the number of songs beaten in descending order, with the smaller id first on ties, separated by spaces.

样例 1

输入:

3 3
0 1 2
0 2 1
1 2 0

输出:

0 1 2

样例 2

输入:

2 2
0 1
1 0

输出:

0 1

样例 3

输入:

1 1
0

输出:

0