407412: GYM102785 H A self-describing sequence
Description
Let's call the sequence $$$a_0$$$, $$$a_1$$$, $$$a_2$$$, … $$$a_{k-1}$$$ as «self- describing»; if the value $$$a_i$$$ is the number of numbers $$$i$$$ encountered in this sequence.
For example, in a sequence 1, 2, 1, 0 - «0» occurs 1 time, «1» is found 2 times, «2» occurs once and «3» does not occur.
Your task will be to write a program that for a given length of sequence $$$k$$$, will output its elements with the specified indices, or report that such a sequence does not exist. If there are several such sequences, any of them is considered to be correct.
InputThe first line of the input file contains the length of the sequence $$$k$$$. $$$(1~\le~k~\le~2^{30})$$$.
The second line of the input file contains the number $$$n$$$ $$$(0~<~n~\le~10^5)$$$ which is the number of elements to be found in the sequence.
The third line contains the $$$n$$$ number of integers $$$r_1$$$ $$$r_2$$$ $$$r_3$$$ … $$$r_n$$$ $$$(0~\le~n_i~<~k)$$$, separated by spaces. These are the indices of those elements of the sequence which are to be put out.
OutputThe first line of the output file contains 0 if the «self-describing» sequence of length $$$k$$$ does not exist. Otherwise, the first line contains the number $$$n$$$, further, in the second line of the output file it is situated by the $$$n$$$ numbers separated by spaces — elements of the sequence with the indices specified in the input file in the order of appearance of these indices in the input file.
ExamplesInput4Output
4
0 1 2 3
4Input
1 2 1 0
4Output
4
3 2 1 0
4Input
0 1 2 1
1Output
1
0
0Input
5Output
3
4 4 4
3
0 0 0