UberOA #63
Tournament Rounds by Rank
估计简单可在线判题
考点(AI 标注)模拟/实现
Adjacent pairs of players compete, and the one with the smaller rank number advances. When a round has an odd number of players, the last one advances automatically. Output the list after each round, keeping the original match order, until only one player remains; do not output the initial list.
This site has made the standard input and output explicit.
输入格式
The first line contains n, and the second line contains n distinct ranks. On this site 1≤n≤200000 and 1≤rank≤10⁹.
输出格式
The first line is the number of rounds R; then one line per round, giving the number of advancing players followed by their ranks.
样例 1
输入:
8
1 2 3 4 5 6 7 8
输出:
3
4 1 3 5 7
2 1 5
1 1
样例 2
输入:
3
3 1 2
输出:
2
2 1 2
1 1
样例 3
输入:
1
5
输出:
0
样例说明
Example 1: the three rounds are 1 3 5 7, 1 5, and 1. Example 2: in the first round 1 beats 3 and 2 gets a bye, giving 1 2; in the second round 1 advances. Example 3: only one player remains from the start, so there are no knockout rounds; output 0 rounds.