CF1641B Repetitions Decoding
Description
Input Format
Output Format
Explanation/Hint
In the fourth test case, initially, we have the following array: $ $ [3, 2, 1, 1, 2, 3]. $ $ After the first insertion with $ p = 0, c = 3 $ : $ $ [\textbf{3, 3}, 3, 2, 1, 1, 2, 3]. $ $ After the second insertion with $ p = 8, c = 3 $ : $ $ [3, 3, 3, 2, 1, 1, 2, 3, \textbf{3, 3}]. $ $ After the third insertion with $ p = 5, c = 3 $ $ $ [3, 3, 3, 2, 1, \textbf{3, 3}, 1, 2, 3, 3, 3]. $ $ After the fourth insertion with $ p = 6, c = 2 $ : $ $ [3, 3, 3, 2, 1, 3, \textbf{2, 2}, 3, 1, 2, 3, 3, 3]. $ $ After the fifth insertion with $ p = 7, c = 1 $ : $ $ [3, 3, 3, 2, 1, 3, 2, \textbf{1, 1}, 2, 3, 1, 2, 3, 3, 3]. $ $ The resulting array can be represented as a concatenation of tandem repeats: $ $ \underbrace{([3] + [3])}_{t_1 = 2} + \underbrace{([3, 2, 1] + [3, 2, 1])}_{t_2 = 6} + \underbrace{([1, 2, 3] + [1, 2, 3])}_{t_3 = 6} + \underbrace{([3] + [3])}_{t_4 = 2}. $ $$$