atcoder#AGC049B. [AGC049B] Flip Digits
[AGC049B] Flip Digits
Score : points
Problem Statement
Given are length- strings and consisting of 0 and 1.
You can do the following operation on any number of times:
- Choose () such that
1, and replace with0. Additionally, invert , that is, change it to1if it is0now and vice versa.
Is it possible to make exactly match ? If it is possible, how many operations does it take at least?
Constraints
- is a string of length consisting of
0and1. - is a string of length consisting of
0and1.
Input
Input is given from Standard Input in the following format:
Output
If it is possible to make exactly match , print the minimum number of operations it takes. Otherwise, print .
3
001
100
2
We can do as follows: 001 → (choose ) → 010 → (choose ) → 100.
3
001
110
-1
5
10111
01010
5