#P12801. [NERC 2022] Lisa's Sequences
[NERC 2022] Lisa's Sequences
题目描述
Lisa loves playing with the sequences of integers. When she gets a new integer sequence of length , she starts looking for all subsequences. A monotone subsequence is defined by two indices and () such that or .
Lisa considers a sequence to be if there is a monotone subsequence that is as long as her boredom threshold , that is when .
Lucas has a sequence that he wants to present to Lisa, but the sequence might be boring for Lisa. So, he wants to change some elements of his sequence , so that Lisa does not get bored playing with it. However, Lucas is lazy and wants to change as few elements of the sequence as possible. Your task is to help Lucas find the required changes.
输入格式
The first line of the input contains two integers and () --- the length of the sequence and Lisa's boredom threshold. The second line contains integers () --- the original sequence that Lucas has.
输出格式
On the first line output an integer --- the minimal number of elements in that needs to be changed to make the sequence not boring for Lisa. On the second line output integers (), so that the sequence of integers is not boring for Lisa and is different from the original sequence in exactly positions.
5 3
1 2 3 4 5
2
1 0 3 0 5
6 3
1 1 1 1 1 1
3
1 100000 0 1 0 1
6 4
1 1 4 4 1 1
1
1 1 4 0 1 1
6 4
4 4 4 2 2 2
2
4 4 0 2 0 2
6 4
4 4 4 3 4 4
1
4 4 100000 3 4 4
8 4
2 1 1 3 3 1 1 2
2
2 1 1 3 0 1 0 2
10 4
1 1 1 2 2 1 1 2 2 1
2
1 1 100000 2 2 100000 1 2 2 1
7 5
5 4 4 3 4 4 4
0
5 4 4 3 4 4 4
10 10
1 1 1 1 1 1 1 1 1 1
1
1 1 1 1 1 1 1 1 0 1