The official analysis is hard to understand. Any other explanations please?
№ | Пользователь | Рейтинг |
---|---|---|
1 | tourist | 3993 |
2 | jiangly | 3743 |
3 | orzdevinwang | 3707 |
4 | Radewoosh | 3627 |
5 | jqdai0815 | 3620 |
6 | Benq | 3564 |
7 | Kevin114514 | 3443 |
8 | ksun48 | 3434 |
9 | Rewinding | 3397 |
10 | Um_nik | 3396 |
Страны | Города | Организации | Всё → |
№ | Пользователь | Вклад |
---|---|---|
1 | cry | 167 |
2 | Um_nik | 163 |
3 | maomao90 | 162 |
3 | atcoder_official | 162 |
5 | adamant | 159 |
6 | -is-this-fft- | 158 |
7 | awoo | 155 |
8 | TheScrasse | 154 |
9 | Dominater069 | 153 |
10 | nor | 152 |
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!