Hide

Problem L
Jack the Mole

Accepted submissions to this problem will be granted a score of 77
/problems/jackthemole/file/statement/en/img-0001.jpg
CC BY-SA 3.0 By Kenneth Catania

The spy agency you are employed by1 has sent you and some fellow spies on an important mission deep in the jungles of Luxembourg. Your colleagues and you are currently waiting on an abandoned and overgrown airstrip, about to be picked up by the finest spy plane the Dutch bureaucracy can buy.

However, an urgent communication from the HQ has just come in to inform you counterintelligence has learned that during the mission, an infamous counter-spy called Jack the Mole was planted among you! You do a headcount and to your horror realize that while you started the mission with $n-1$ people, there are now $n$!2 Since you all take Covid regulations very seriously, you all wore masks, so it is not obvious who the imposter is.

Then you remember: the finest spy plane in question is thrown off balance rather easily, so the agency picked the $n-1$ agents so that it is possible to divide them into two groups of equal weight, but not necessarily of equal size, for the left and the right side of the plane respectively. However, it did not specify exactly which two groups (anonymity and all that). Of course you have a scale with you (doesn’t any good spy?), so you can find which of the $n$ people on the mission is potentially the mole.

Input

The input consists of:

  • One line containing an integer $n$ ($3 \leq n \leq 300$), the number of spies present.

  • One line containing $n$ integers $w_1, \ldots , w_n$ ($1\leq w_{i} \leq 1000$), the $i$th of which gives the weight of the $i$th spy in kilograms3.

Output

Output a single number $k$, the number of spies that are potentially the mole, followed by $k$ integers, the suspects, in increasing order.

Sample Input 1 Sample Output 1
3
1 1 2
1
3
Sample Input 2 Sample Output 2
3
1 1 1
3
1 2 3
Sample Input 3 Sample Output 3
5
2 1 3 4 2
3
1 4 5
Sample Input 4 Sample Output 4
5
1 1 1 3 1
5
1 2 3 4 5
Sample Input 5 Sample Output 5
4
2 1 5 3
2
2 3

Footnotes

  1. When your family members ask, please lie to them and say you work as a computer programmer.
  2. Exclamation point, not factorial.
  3. If those ranges seem odd, recall spies can be very muscular or very nimble.

Please log in to submit a solution to this problem

Log in