Problem E
Simone
blue red blue green blue blue
green
The sequence stops. Now you repeat it.
Consider the following generalization Simone of this classic game. In Simone, a sequence of lights of $K$ different colours will flash; the player must memorize this sequence and play it back. Simone is such a popular game that it has become a game show played during prime time TV.
You are working behind the scenes during a live taping of this show. Unfortunately, the random number generator has stopped working! Quickly, pick a colour that should be added to the sequence the contestant just successfully repeated!
You decide to pick a colour that has appeared the least frequently in the sequence. Which colours can you choose from?
Input
The first line of input contains two integers $N,K$ where $N$ ($1 \leq N \leq 1\, 000$) is the length of the sequence played so far and $K$ ($1 \leq K \leq 1\, 000$) is the number of colours available to use.
The second line consists of $N$ space-separated integers, each between $1$ and $K$. This is the sequence of colours the contestant just successfully repeated.
Output
The first line of output contains a single integer $M$ indicating the number of colours from $1$ to $K$ (inclusive) that appear the least frequently in the sequence. The second line lists these colours in increasing order with a single space between consecutive numbers.
Sample Input 1 | Sample Output 1 |
---|---|
5 3 1 3 1 2 3 |
1 2 |
Sample Input 2 | Sample Output 2 |
---|---|
4 3 1 2 1 3 |
2 2 3 |
Sample Input 3 | Sample Output 3 |
---|---|
3 5 1 3 4 |
2 2 5 |
Sample Input 4 | Sample Output 4 |
---|---|
4 4 4 2 1 3 |
4 1 2 3 4 |