Lowkey the last D1B (2255B) felt extremely hard (mainly my skill issue) and I couldn't really understand the editorial. Can someone here explain it to me so i can understand it ty :)
| # | User | Rating |
|---|---|---|
| 1 | Benq | 3857 |
| 2 | jiangly | 3810 |
| 3 | maroonrk | 3534 |
| 4 | tourist | 3528 |
| 5 | Kevin114514 | 3510 |
| 6 | turmax | 3411 |
| 7 | Um_nik | 3387 |
| 8 | Radewoosh | 3367 |
| 9 | heuristica | 3322 |
| 10 | strapple | 3317 |
| # | User | Contrib. |
|---|---|---|
| 1 | Qingyu | 158 |
| 2 | maspy | 150 |
| 3 | Um_nik | 146 |
| 4 | Errichto | 139 |
| 5 | adamant | 136 |
| 6 | maroonrk | 134 |
| 7 | DNR | 133 |
| 8 | nik_exists | 132 |
| 9 | Dominater069 | 131 |
| 10 | Proof_by_QED | 130 |
| Name |
|---|



Lets suppose we are performing the operation on $$$s_i,...,s_j$$$. Now we know that if we are performing the operation $$$s_i=s_j$$$ must always be true. Lets split the sequence we are operating on into blocks of $$$0$$$ and $$$1$$$. When we reverse the substring the number of blocks of $$$1$$$ and the number of blocks of $$$0$$$ will remain the same.
The important thing to note is that the number of blocks of $$$0$$$ and $$$1$$$ in the string outside of the region we are operating on will also not be changed by the operation. This is because the boundary elements are the same: if $$$s_{i-1}$$$ is the same or different from $$$s_i$$$, it would remain so because the value of $$$s_i$$$ remains the same after we reverse. The same is true for $$$s_j$$$ and $$$s_{j+1}$$$. Since the reversal can only affect elements outside the substring that are on the boundary of the substring, and we have shown that the reversal has no effect on the boundary elements, it is now proven that the number of blocks of $$$1$$$ and number of blocks of $$$0$$$ in the whole array will remain constant no matter what and how many operations we do.
Since we can do an infinite amount of operations on whichever positions we want, and operations can change the length of blocks, we can create any possible string that has the same number of blocks of $$$1$$$ and same number of blocks of $$$0$$$ as the original string.
Now we just need to compute the total number of such strings. IF original string has $$$C_1$$$ $$$1$$$ and $$$C_0$$$ $$$0$$$, and has $$$B_1$$$ blocks of $$$1$$$ and $$$B_0$$$ blocks of $$$0$$$, we can use stars and bars approach to find the answer:
You're the goat dude <3