#P10164. [DTCPC 2024] 戈布
[DTCPC 2024] 戈布
Problem Description
For a sequence , find the minimum such that there exists a set that satisfies the following condition.
- , if and only if , .
It can be proven that the set that satisfies the condition is unique.
A sequence is good if and only if , .
In simple terms, a sequence is good if and only if the lengths of the maximal consecutive segments of formed from left to right are strictly increasing.
Given the sequence , you may perform the following operation any number of times (or do nothing):
- Choose and swap .
Find the minimum number of operations needed to make a good sequence.
Input Format
One line containing a sequence of length ().
Output Format
One line containing one number, which is the answer.
01101
1
01011
0
Hint
Translated by ChatGPT 5