#P1558. 色板游戏
色板游戏
Description
The color board has length , where is a positive integer, so we can evenly divide it into small squares, each centimeter long, labeled from left to right as .
Currently the board has only one color. The teacher tells Abao that only two operations are allowed on the board:
C A B Cmeans to paint all squares numbered from to with color .P A Bmeans a query: how many different colors appear among squares numbered from to .
There are types of paint in the school’s paint box. For simplicity, we label them as . Initially, the entire board has color . Facing such a complex problem, Abao asks for your help. Can you help him?
Input Format
The first line contains integers , , and . Here is the number of operations.
Then follow lines, each describing an operation in the form C A B C or P A B (here are integers; it is possible that , in which case you should swap and ).
Output Format
For each query from the teacher, output the corresponding answer. Print one integer per line.
2 2 4
C 1 1 2
P 1 2
C 2 2 2
P 1 2
2
1
Hint
Constraints
, , .
(not guaranteed that ), .
Translated by ChatGPT 5
京公网安备 11011102002149号