#P10160. [DTCPC 2024] Ultra
[DTCPC 2024] Ultra
Background
Tony2 likes playing a certain two-character game. One day, he showed his in front of Xiao C.
But Xiao C does not know how to , so he went to Tutu-jiang.
Then Tutu failed
So while Tony2 was not around, Xiao C secretly swapped his jump key and down-dash key. (
Problem Description
Tony2’s actions can be seen as a combination of down-dash and jump.
An is defined as a continuous segment of actions: it starts with a down-dash, then jump and down-dash alternate, and it ends with a down-dash. Since it is an , it must contain at least one jump.
Each time, Xiao C can turn an into , that is, within this , change every down-dash into a jump, and change every jump into a down-dash.
Xiao C does not like , so he wants the number of down-dashes to be as small as possible.
Formal statement
You are given a sequence. You may perform the following operation any number of times (possibly zero times):
- Replace a substring of the form (i.e., , ) with an equal-length substring (i.e., ).
Your goal is to make the number of ’s as small as possible. Output the minimum possible number of ’s.
Input Format
One line contains a string of length () representing this sequence.
Output Format
Output one number, the minimum possible number of ’s.
1010011
3
Hint
Explanation for sample : choose the first three characters . After applying the operation, the string becomes , which contains only ones. It is easy to prove that this is optimal.
Translated by ChatGPT 5