The official analysis is hard to understand. Any other explanations please?
# | User | Rating |
---|---|---|
1 | tourist | 3985 |
2 | jiangly | 3814 |
3 | jqdai0815 | 3682 |
4 | Benq | 3529 |
5 | orzdevinwang | 3526 |
6 | ksun48 | 3517 |
7 | Radewoosh | 3410 |
8 | hos.lyric | 3399 |
9 | ecnerwala | 3392 |
9 | Um_nik | 3392 |
# | User | Contrib. |
---|---|---|
1 | cry | 169 |
2 | maomao90 | 162 |
2 | Um_nik | 162 |
4 | atcoder_official | 161 |
5 | djm03178 | 158 |
6 | -is-this-fft- | 157 |
7 | adamant | 155 |
8 | awoo | 154 |
8 | Dominater069 | 154 |
10 | luogu_official | 150 |
The official analysis is hard to understand. Any other explanations please?
Name |
---|
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!