#Lutece2950. Colorful Scarf
Colorful Scarf
Migrated from Lutece 2950 Colorful Scarf
All parts of this problem, including description, images, samples, data and checker, might be broken. If you find bugs in this problem, please contact the admins.
Description
本题解法:启发式合并/线段树合并 注意:u和v可能相同 blackbird买了一条新围巾,它是由 块不同颜色的布料顺次拼接而成的,第 块布料的颜色是 。 blackbird对围巾的颜色不太满意,于是找来颜料和刷子。由于它很笨,每次操作只能将某一种颜色的布料全部涂成另一种颜色。同时,它还想知道当前围巾上有多少颜色段(详见样例解释)。
Input
第一行两个整数 ,分别表示布料的块数和操作次数。 第二行 个整数 , 分别表示每一块的颜色。 接下来 行,首先输入一个整数
- 如果 , 接着输入两个整数 ,表示将所有颜色为 的块涂成颜色 。
- 如果 , 表示询问当前围巾上有多少个颜色段。
Output
对于每个询问,输出一行一个整数,表示当前围巾上有多少个颜色段。
Samples
6 5
1 1 4 5 1 4
2
1 5 4
2
1 4 1
2
5
4
1
Constraints
Note
第一次涂色前,围巾上有 五个颜色段。 第一次涂色后,围巾上有 四个颜色段。 第二次涂色后,围巾上有 一个颜色段。
Resources
2023 UESTC ICPC Training for Data Structures