P10164 [DTCPC 2024] Gob
Description
For a $01$ sequence $\{a_n\}$, find the minimum $k$ such that there exists a set $\{(l_k,r_k)\}$ that satisfies the following condition.
- $\forall i\in[1,n]$, $a_i=1$ if and only if $\exist j\in[1,k]$, $i\in[l_j,r_j]$.
It can be proven that the set $\{(l_k,r_k)\}$ that satisfies the condition is unique.
A $01$ sequence $\{a_n\}$ is good if and only if $\forall i\in[1,k)$, $r_i-l_i
Input Format
One line containing a $01$ sequence $\{a_n\}$ of length $n$ ($n\leq 800$).
Output Format
One line containing one number, which is the answer.
Explanation/Hint
Translated by ChatGPT 5