| CPUlm Winter Contest 2022 |
|---|
| Finished |
You may know Wizard's Chess, which is a magical version of chess, but there are more magical games in the wizarding world. Another one you may recognize is Magic Marbles, which is similar to the muggle game Marble Temple. In this game, you are given a chain of differently coloured marbles $$$m$$$, which you need to destroy. To do this, you can add additional marbles to the chain. This may sound counterproductive, but if there ever is a run of at least $$$k$$$ consecutive marbles that are of the same colour, then all of these marbles magically disappear instantly. The resulting gap is closed by moving the remaining marbles closer together, which can lead to new runs that then again disappear.
The initial state of the first sample. The first marble will be added between the second yellow marble and the first blue marble. Since this results in a run of three blue marbles, all of them instantly disappear. This year there is a great Magic Marbles tournament in Hogwarts. However, you fear that some magicians are not as sincere as you and may try to cheat in this magic tournament. Therefore, you decided to simulate the game without magic.
The input consists of:
For each of the $$$q$$$ insertions of a new marble, output a single integer $$$|m|$$$, the length of the marble chain after that insertion and any deletions that were caused by it.
7 3 2 1 2 2 1 3 3 1 4 3 3 2
5 0
5 2 3 1 2 1 2 3 0 1 1 1 0 3
4 1 0
| Name |
|---|


