CF1215E Marbles
题目描述
## 题目大意
有 n $ (n \le 4 * 10^5) $ 个珠子 , 第$i$个珠子颜色是$ c_i (c_i \le 20)$ , 每次操作把**相邻**的两个珠子交换。现在要把相同颜色的珠子排列在相连的一段,问至少要多少次操作 。
输入格式
无
输出格式
无
说明/提示
In the first example three operations are enough. Firstly, Monocarp should swap the third and the fourth marbles, so the sequence of colors is $ [3, 4, 3, 2, 4, 2, 2] $ . Then Monocarp should swap the second and the third marbles, so the sequence is $ [3, 3, 4, 2, 4, 2, 2] $ . And finally, Monocarp should swap the fourth and the fifth marbles, so the sequence is $ [3, 3, 4, 4, 2, 2, 2] $ .
In the second example there's no need to perform any operations.