Counting Friends
Time limit1sMemory limit128 MB
Removing one of N+1 listed counts, find every entry whose removal leaves counts realizable as mutual friendships among N cows.
Problem
Farmer John has cows () on the social network MooBook.
Each cow has one or more friends on MooBook. While writing down every cow's friend count, Farmer John got distracted and accidentally wrote one extra number. His list therefore has entries instead of .
Find every entry that could be the mistaken extra number.
Input
- Line 1: integer
- Lines 2 through : one integer per line, either a cow's friend count or the extra mistaken number
Output
- Line 1: integer , the number of entries that could be the extra number ( means no removal leaves a valid friend assignment)
- Next lines: indices from 1 through in the input order. Print an index if removing that entry leaves counts that can be realized as mutual friendships among cows. Print indices in sorted order.