Kool Strings
면접 대비시간 제한1초메모리 제한2048 MB
이진 문자열 S와 정수 K가 주어질 때, 같은 문자가 K개 이상 연속하지 않도록 최소 횟수로 문자를 뒤집고, 그 횟수와 결과 문자열을 출력한다.
문제
Professor Kardashi is known for always being fashionable and for her passion for computer science. Her current obsessions are binary strings and efficiency. In particular, she says that a binary string is kool if it does not contain or more consecutive identical characters.
To test your skills, Professor Kardashi gives you a binary string and allows you to perform the following operation on it: choose an index and flip the value of (changing a “0” to “1” or a “1” to “0”).
Your task is to transform into a kool string using the minimum number of operations.
입력
The input consists of a single line that contains an integer and a binary string ().
출력
Output a single line with an integer indicating the minimum number of operations needed to transform into a kool string, followed by a kool string that can be obtained after applying that number of operations to . If there are multiple solutions, output any of them.