atcoder#AGC030E. [AGC030E] Less than 3
[AGC030E] Less than 3
Score : points
Problem Statement
You are given strings and , both of length .
and consist of 0 and 1. Additionally, in these strings, the same character never occurs three or more times in a row.
You can modify by repeatedly performing the following operation:
- Choose an index () freely and invert the -th character in (that is, replace
0with1, and1with0), under the condition that the same character would not occur three or more times in a row in after the operation.
Your objective is to make equal to . Find the minimum number of operations required.
Constraints
- The lengths of and are both .
- and consists of
0and1. - In and , the same character never occurs three or more times in a row.
Input
Input is given from Standard Input in the following format:
Output
Find the minimum number of operations required to make equal to . It can be proved that the objective is always achievable in a finite number of operations.
4
0011
0101
4
One possible solution is 0011 → 1011 → 1001 → 1101 → 0101.
1
0
0
0
8
00110011
10101010
10