CF1515H.Phoenix and Bits
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Phoenix loves playing with bits — specifically, by using the bitwise operations AND, OR, and XOR. He has n integers a1,a2,…,an , and will perform q of the following queries:
- replace all numbers ai where l≤ai≤r with ai AND x ;
- replace all numbers ai where l≤ai≤r with ai OR x ;
- replace all numbers ai where l≤ai≤r with ai XOR x ;
- output how many distinct integers ai where l≤ai≤r .
For each query, Phoenix is given l , r , and x . Note that he is considering the values of the numbers, not their indices.
输入格式
The first line contains two integers n and q ( 1≤n≤2⋅105 ; 1≤q≤105 ) — the number of integers and the number of queries, respectively.
The second line contains n integers a1,a2,…,an ( 0≤ai<220 ) — the integers that Phoenix starts with.
The next q lines contain the queries. For each query, the first integer of each line is t ( 1≤t≤4 ) — the type of query.
If t∈{1,2,3} , then three integers li , ri , and xi will follow ( 0≤li,ri,xi<220 ; li≤ri ).
Otherwise, if t=4 , two integers li and ri will follow ( 0≤li≤ri<220 ).
It is guaranteed that there is at least one query where t=4 .
输出格式
Print the answer for each query where t=4 .
输入输出样例
输入#1
5 6 5 4 3 2 1 1 2 3 2 4 2 5 3 2 5 3 4 1 6 2 1 1 8 4 8 10
输出#1
3 2 1
输入#2
6 7 6 0 2 3 2 7 1 0 4 3 2 6 8 4 4 0 7 3 2 5 3 1 0 1 2 4 0 3 4 2 7
输出#2
5 1 2
说明/提示
In the first example:
- For the first query, 2 is replaced by 2 AND 2=2 and 3 is replaced with 3 AND 2=2 . The set of numbers is {1,2,4,5} .
- For the second query, there are 3 distinct numbers between 2 and 5 : 2 , 4 , and 5 .
- For the third query, 2 is replaced by 2 XOR 3=1 , 4 is replaced by 4 XOR 3=7 , and 5 is replaced by 5 XOR 3=6 . The set of numbers is {1,6,7} .
- For the fourth query, there are 2 distinct numbers between 1 and 6 : 1 and 6 .
- For the fifth query, 1 is replaced by 1 OR 8=9 . The set of numbers is {6,7,9} .
- For the sixth query, there is one distinct number between 8 and 10 : 9 .