#P3201. [HNOI2009] 梦幻布丁
[HNOI2009] 梦幻布丁
Description
There are puddings in a line, and we will perform operations. An operation may recolor all puddings of one color into another color, or ask how many color segments there are at the moment.
For example, four puddings with colors have color segments.
Input Format
The first line contains two integers, the number of puddings and the number of operations .
The second line contains integers; the -th integer is the color of the -th pudding.
Then there are lines, each describing one operation. Each line starts with an integer indicating the type:
- If , then two integers follow, meaning recolor all puddings of color to color .
- If , it denotes a query.
Output Format
For each query, output one integer on a single line, indicating the answer.
4 3
1 2 2 1
2
1 2 1
2
3
1
Hint
Sample 1 Explanation
Initially the colors are , and the three color segments are .
After one operation, the colors become , leaving only one segment .
Constraints
For all test points, it is guaranteed that , .
Notes
Please note that it is not guaranteed that color IDs are at most , it is also not guaranteed that , and is not an upper bound on color IDs.
Translated by ChatGPT 5
京公网安备 11011102002149号