CF1404A Balanced Bitstring
Description
A bitstring is a string consisting only of the characters 0 and 1. A bitstring is called $ k $ -balanced if every substring of size $ k $ of this bitstring has an equal amount of 0 and 1 characters ( $ \frac{k}{2} $ of each).
You are given an integer $ k $ and a string $ s $ which is composed only of characters 0, 1, and ?. You need to determine whether you can make a $ k $ -balanced bitstring by replacing every ? characters in $ s $ with either 0 or 1.
A string $ a $ is a substring of a string $ b $ if $ a $ can be obtained from $ b $ by deletion of several (possibly, zero or all) characters from the beginning and several (possibly, zero or all) characters from the end.
Input Format
N/A
Output Format
N/A
Explanation/Hint
For the first test case, the string is already a $ 4 $ -balanced bitstring.
For the second test case, the string can be transformed into 101.
For the fourth test case, the string can be transformed into 0110.
For the fifth test case, the string can be transformed into 1100110.