Even-Sum Sequence
Time limit1sMemory limit256 MB
Replace the fewest entries so every length-k window sum is even, then output the lexicographically smallest such sequence.
Problem
You are given an integer sequence . If is even for every integer with , the sequence is called a -even-sum sequence.
You can replace some elements of the sequence with any integers you want. Find the minimum number of elements you have to replace to turn the sequence into a -even-sum sequence, and print the sequence you get.
Input
The first line has the integers and . ()
The second line has integers. The -th of them is . ()
Output
On the first line print the minimum number of elements that have to be replaced.
On the second line print the elements of the finished sequence, separated by single spaces. Every element must satisfy .
If several sequences reach that minimum, print the lexicographically smallest one. Between two sequences of the same length, the one holding the smaller value at the first position where they differ comes first.