Wrong output in several cases

Hello @samadsid7,

You would laugh after knowing your mistake and you should.
These are very small mistakes but can cause frustation. So, start avoiding them.
Solution:
Read the entire question properly.

The entire logic of your code is correct.
But the problem is with the output format of your code.
It does not matches with the output format of the question:
Example:
10 2
1 0 0 1 0 1 0 1 0 1
Your Output:
5
1001111101
Expected Output:
5
1 0 0 1 1 1 1 1 0 1

Can you see the difference? Great.
Do the necessary modification and your code will pass all the testcases.

Hope, this would help.
Give a like, if you are satisfied.