[USACO 2014 Mar G]Counting Friends
题号:NC24590
时间限制:C/C++/Rust/Pascal 1秒,其他语言2秒
空间限制:C/C++/Rust/Pascal 256 M,其他语言512 M
64bit IO Format: %lld

题目描述

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. Just
for fun, Farmer John makes a list of the number of friends for each of his
cows, but during the process of writing the list 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.

输入描述:

* 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.

输出描述:

* Line 1: An integer K giving the number of entries in FJ's list that
could be the extra number (or, K=0 means that there is no
number on the list whose removal yields a feasible pairing of
friends).

* Lines 2..1+K: Each line contains the index (1..N+1) within the input
ordering of a number of FJ's list that could potentially be
the extra number -- that is, a number that can be removed such
that the remaining N numbers admit a feasible set of
friendships among the cows. These lines should be in sorted
order.
示例1

输入

复制
4
1
2
2
1
3

输出

复制
3
1
4
5