#P9202. 「GMOI R2-T2」猫耳小(加强版)
「GMOI R2-T2」猫耳小(加强版)
Background
The difference between this problem and the original problem is the constraints and the output format. In this version, and the value range is . You need to output a construction.

Problem Description
Little R is a cute cat-eared girl. She likes studying the of sequences.
Now she has a sequence of length . She hates the integer , so she wants to modify some elements of into any natural numbers, such that the of every non-empty contiguous subarray of is not equal to .
Please find the minimum number of elements that need to be modified, and output one valid plan.
In this problem, the of a sequence is defined as the smallest natural number that does not appear in the sequence. For example:
- , because is a natural number.
- .
- .
Input Format
The first line contains two integers , representing the length of the sequence and the number that Little R hates.
The second line contains integers. The -th integer is , representing the -th element of the sequence.
Output Format
The first line contains one integer, representing the minimum number of modified elements.
The second line contains integers, representing the modified sequence. You need to ensure that every number in the modified sequence is within .
5 2
1 0 1 3 0
2
1 1 1 3 2
Hint
Explanation of the sample
One possible plan is to change into , modifying elements in total.
It can be proven that no better plan exists.
Scoring
This problem uses a special judge (Special Judge) for evaluation.
For each test point, if your minimum number of steps is correct, you can get of the score. Based on this, if your construction is also correct, you can get full marks.
Note: Even if you cannot output a construction, you still need to output integers on the second line according to the output format.
This problem uses bundled tests, with no subtasks.
For of the testdata, , .
The I/O volume of this problem is large, so it is recommended to use fast I/O methods.
Translated by ChatGPT 5