#ARC132D. [ARC132D] Between Two Binary Strings
[ARC132D] Between Two Binary Strings
Score : points
Problem Statement
Let us define the beauty of the string as the number of positions where two adjacent characters are the same.
For example, the beauty of 00011 is , and the beauty of 10101 is .
Let be the set of all strings of length formed of 0s and 1s.
For , let us define the distance of and , , as the minimum number of swaps needed when rearranging the string to by swaps of two adjacent characters.
Additionally, for , is said to be between and when .
Given , print the greatest beauty of a string between and .
Constraints
- Each of and is a string of length formed of
0s and1s.
Input
Input is given from Standard Input in the following format:
Output
Print the greatest beauty of a string between and .
2 3
10110
01101
2
Between 10110 and 01101, whose distance is , we have the following strings: 10110, 01110, 01101, 10101.
Their beauties are , , , , respectively, so the answer is .
4 2
000011
110000
4
Between 000011 and 110000, whose distance is , the strings with the greatest beauty are 000011 and 110000, so the answer is .
12 26
01110111101110111101001101111010110110
10011110111011011001111011111101001110
22