The official analysis is hard to understand. Any other explanations please?
№ | Пользователь | Рейтинг |
---|---|---|
1 | tourist | 4009 |
2 | jiangly | 3823 |
3 | Benq | 3738 |
4 | Radewoosh | 3633 |
5 | jqdai0815 | 3620 |
6 | orzdevinwang | 3529 |
7 | ecnerwala | 3446 |
8 | Um_nik | 3396 |
9 | ksun48 | 3390 |
10 | gamegame | 3386 |
Страны | Города | Организации | Всё → |
№ | Пользователь | Вклад |
---|---|---|
1 | cry | 167 |
2 | Um_nik | 163 |
3 | maomao90 | 162 |
3 | atcoder_official | 162 |
5 | adamant | 159 |
6 | -is-this-fft- | 158 |
7 | awoo | 157 |
8 | TheScrasse | 154 |
9 | Dominater069 | 153 |
9 | nor | 153 |
The official analysis is hard to understand. Any other explanations please?
Название |
---|
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).
Thanks A LOT for this explanation!