#7395. [UOI 2025 II Stage] Three Queries
[UOI 2025 II Stage] Three Queries
[UOI 2025 II Stage] Three Queries
题目描述
Given an array $a$ of length $n$ and $q$ queries. We also have a binary array $w$ of infinite length, initially all $w_i=1$.There are three types of queries:
- --- toggle the value of (from to , and vice versa).
- --- count the number of unique numbers in the array in the range for which and .
- --- assign the value to .
Provide an answer for each query of the second type.
输入格式
The first line contains two integers $n$ and $q$ $(1 \le n, q \le 3\cdot10^5)$~--- the length of the array and the number of queries.The second line contains integers ~--- the values of the elements of the array.
Each of the following lines starts with an integer --- the type number of each query:
- If , the query contains one integer --- toggle the value of .
- If , the query contains two integers and --- count the number of unique numbers in the array in the range for which and .
- If , the query contains two integers and --- replace the value of with .
输出格式
For each query of the second type, output the number of unique numbers in the range on a separate line.10 5
3 4 3 4 3 2 3 1 2 1
2 2 5
1 3
2 2 5
3 4 5
2 2 5
2
1
2
提示
In the example for the first query of the second type, the segment looks like $[4, 3, 4, 3]$, meaning there are numbers $3$, $4$, and $w_3$, $w_4$ are equal to $1$, so the answer is $2$. After the next query of type $1$, $w_3$ becomes $0$, so for the next query, the answer is $1$. After the next query, the array will look like $[3, 4, 3, 5, 3, 2, 3, 1, 2, 1]$. In the last query, the segment will look like $[4, 3, 5, 3]$, meaning there are numbers $3, 4, 5$, respectively the answer is $2$, because $w_3 = 0$.Scoring
- ( points): ;
- ( points): only queries of type ; ; ;
- ( points): only queries of type ;
- ( points): only queries of type and ; all are pairwise distinct;
- ( points): only queries of type and ; all can change only once;
- ( points): only queries of type and ;
- ( points): only queries of type and ;
- ( points): at any moment, ;
- ( points): ;
- ( points): without additional constraints. 标签: P15094|2025|分块|UOI(乌克兰)