#P7285. 「EZEC-5」修改数组
「EZEC-5」修改数组
Description
Given an array of length whose elements are or .
Now you may choose some (possibly ) elements with value and change them to .
Let:
- be the length of the longest consecutive subarray of s (by definition, if all numbers are , then );
- be the number of modified elements.
Find how to modify the array to maximize , and construct one valid plan (output the modified array).
Input Format
This problem contains multiple test cases.
The first line contains an integer indicating the number of test cases.
The next lines describe the test cases, where every lines correspond to one test case.
In each test case, the first line contains an integer , the length of the array.
The second line contains integers ( or ), representing the given array.
Output Format
Output a total of lines, where every lines correspond to one test case.
In each test case, on the first line output an integer, the maximum value of .
On the second line output integers ( or ), representing the modified array. If there are multiple solutions, output any one of them.
1
1
1
1
1
2
3
1 0 1
5
0 1 0 1 0
2
1 1 1
2
0 1 1 1 1
Hint
This problem uses bundled tests.
For all testdata, it is guaranteed that and , and the array elements .
- Subtask 1 (70 points): .
- Subtask 2 (30 points): no additional constraints.
Translated by ChatGPT 5
京公网安备 11011102002149号