Rating changes for last rounds are temporarily rolled back. They will be returned soon. ×

Real_Father_Of_Ash's blog

By Real_Father_Of_Ash, 3 years ago, In English

The official analysis is hard to understand. Any other explanations please?

»
3 years ago, # |
  Vote: I like it +31 Vote: I do not like it

First notice that it is easier understand the operation when you compress the string. Compressing a string is just grouping adjacent characters, so "110001" will be compressed into [2, 3, 1] because it has 2 ones, then 3 zeros and finally a single one.

Then, when you have a compressed string $$$(k_i)_{1\le i\le n}$$$, a not operation removes the first element of the sequence, while a double operator makes $$$n$$$ even and adds 1 to the last element of the sequence.

Notice that with operations not, you will remove a prefix of the initial string, so you can iterate on the length of the prefix you remove. What is left must be equal to a prefix of the wanted string (except potentially the last character). Then it's just some case analysis to complete the prefix (delete the prefix and double to make the correct solution).