#PS0000173. Những người có thể vô địch (Accidental Victory)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Những người có thể vô địch (Accidental Victory)
Accidental Victory
Source: Codeforces
Version: Phuoc Hung OJ Extended
Problem Statement
There are players numbered 1 through , with initial token counts . Each match selects two players who still have tokens. The one with more tokens wins; a tie is resolved randomly. The winner takes every token of the loser, who is eliminated. After matches one player remains. Every legal random choice has positive probability. Identify every player with a nonzero probability of becoming champion.
Input
Each Phuoc Hung OJ input file contains exactly one test case.
The first line contains integer .
The second line contains the integers in order.
Output
On the first line print the number of possible champions. On the second line print all their indices in increasing order, separated by spaces.
Subtasks
- Subtask 1 (20 points): ; .
- Subtask 2 (30 points): ; ; .
- Subtask 3 (50 points): ; .
Example 1
Input
4
1 2 4 3
Output
3
2 3 4
Explanation
Player 1 cannot win a first match. Player 2 can defeat players 1, 4, 3 in that order, winning ties. Players 3 and 4 can also win by absorbing weaker players first.
Example 2
Input
5
1 1 1 1 1
Output
5
1 2 3 4 5
Explanation
Anyone can win a tie in the first match and then defeat the remaining players.