Problem list
Log in
#usaco0146 · USACO 2013-2014 March Gold

Counting Friends

Platinum IV 2.0 s 256 MB

Farmer John's N cows (2 <= N <= 500) have joined the social network "MooBook".

Each cow has one or more friends with whom they interact on MooBook. Farmer John makes a list of the number of friends for each of his cows, but during the process he becomes distracted, and he includes one extra number by mistake (so his list contains N+1 numbers, instead of N numbers as he intended).

Please help Farmer John figure out which numbers on his list could have been the erroneous extra number.

Input

  • Line 1: The integer N.
  • Lines 2..2+N: Line i+1 contains the number of friends for one of FJ's cows, or possibly the extra erroneous number.

Output

  • Line 1: An integer K giving the number of entries in FJ's list that could be the extra number (K=0 means no number's removal yields a feasible pairing).
  • Lines 2..1+K: Each line contains the index (1..N+1) within the input ordering of a number that could potentially be the extra number, in sorted order.

Example 1

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

Output details: Removing the first "1", the other "1", or the "3" each yields a list admitting a feasible friendship pairing.

Source
USACO 2013-2014 March Gold
Appears in
Not part of a ladder, contest or set yet.
Accepted 0 Submissions 0 Acceptance 0% Solvers 0

Discussion

Threads about this problem. Spoilers are collapsed; wrap hints in ||double bars||.

No discussion yet. Start a thread if something here needs explaining.

Recent submissions Open with filters
Code