#R088B. [ABC083D] Wide Flip
[ABC083D] Wide Flip
Score : points
Problem Statement
You are given a string consisting of 0 and 1.
Find the maximum integer not greater than such that we can turn all the characters of into 0 by repeating the following operation some number of times.
- Choose a contiguous segment in whose length is at least (that is, must be satisfied). For each integer such that , do the following: if is
0, replace it with1; if is1, replace it with0.
Constraints
- is either
0or1.
Input
Input is given from Standard Input in the following format:
Output
Print the maximum integer such that we can turn all the characters of into 0 by repeating the operation some number of times.
010
2
We can turn all the characters of into 0 by the following operations:
- Perform the operation on the segment with length . is now
101. - Perform the operation on the segment with length . is now
011. - Perform the operation on the segment with length . is now
000.
100000000
8
00001111
4