CF587E.Duff as a Queen
省选/NOI-
通过率:0%
时间限制:7.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Duff is the queen of her country, Andarz Gu. She's a competitive programming fan. That's why, when he saw her minister, Malek, free, she gave her a sequence consisting of n non-negative integers, _a_1, _a_2, ..., a__n and asked him to perform q queries for her on this sequence.

There are two types of queries:
- given numbers l, r and k, Malek should perform
for each l ≤ i ≤ r (
, bitwise exclusive OR of numbers a and b). - given numbers l and r Malek should tell her the score of sequence a__l, a__l + 1, ... , a__r.
Score of a sequence _b_1, ..., b__k is the number of its different Kheshtaks. A non-negative integer w is a Kheshtak of this sequence if and only if there exists a subsequence of b, let's denote it as _b__i_1, _b__i_2, ... , b__i__x (possibly empty) such that
(1 ≤ _i_1 < _i_2 < ... < i__x ≤ k). If this subsequence is empty, then w = 0.
Unlike Duff, Malek is not a programmer. That's why he asked for your help. Please help him perform these queries.
达芙是安达尔兹古国的女王,她是一名竞技编程爱好者。因此,当她看到自己的大臣马莱克空闲时,便给了他一个由 n 个非负整数组成的序列 a1,a2,…,an,并要求他对该序列执行 q 个查询。

查询分为两类:
- 给定数字 l、r 和 k,马莱克应对每个满足 l≤i≤r 的下标 i 执行操作:ai←ai⊕k(其中 ⊕ 表示 a 与 b 的按位异或运算)。
- 给定数字 l 和 r,马莱克需报告子序列 al,al+1,…,ar 的“得分”。
序列 b1,…,bk 的得分为其不同的“赫什塔克”(Kheshtak)的个数。一个非负整数 w 是该序列的一个赫什塔克,当且仅当存在 b 的一个子序列(记为 bi1,bi2,…,bix,允许为空),使得
w=bi1⊕bi2⊕⋯⊕bix
(其中 1≤i1<i2<⋯<ix≤k)。若该子序列为空,则 w=0。
与达芙不同,马莱克并非程序员,因此他向你求助。请帮助他完成这些查询。
输入格式
The first line of input contains two integers, n and q (1 ≤ n ≤ 2 × 105 and 1 ≤ q ≤ 4 × 104).
The second line of input contains n integers, _a_1, _a_2, ..., a__n separated by spaces (0 ≤ a__i ≤ 109 for each 1 ≤ i ≤ n).
The next q lines contain the queries. Each line starts with an integer t (1 ≤ t ≤ 2), type of the corresponding query. If t = 1, then there are three more integers in that line, l, r and k. Otherwise there are two more integers, l and r. (1 ≤ l ≤ r ≤ n and 0 ≤ k ≤ 109)
输入的第一行包含两个整数 n 和 q(1≤n≤2×105,1≤q≤4×104)。
输入的第二行包含 n 个整数 a1,a2,…,an,以空格分隔(对每个 1≤i≤n,满足 0≤ai≤109)。
接下来的 q 行表示查询。每行以一个整数 t(1≤t≤2)开头,表示对应查询的类型。若 t=1,则该行还包含另外三个整数 l、r 和 k;否则该行还包含另外两个整数 l 和 r。(满足 1≤l≤r≤n,且 0≤k≤109)
输出格式
Print the answer of each query of the second type in one line.
按行输出每个第二类查询的答案。
输入输出样例
输入#1
5 5 1 2 3 4 2 2 1 5 1 2 2 8 2 1 5 1 1 3 10 2 2 2
输出#1
8 16 1
说明/提示
In the first query, we want all Kheshtaks of sequence 1, 2, 3, 4, 2 which are: 0, 1, 2, 3, 4, 5, 6, 7.
In the third query, we want all Khestaks of sequence 1, 10, 3, 4, 2 which are: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15.
In the fifth query, we want all Kheshtaks of sequence 0 which is 0.
在第一次查询中,我们需要序列 1,2,3,4,2 的所有 Kheshtak,它们是:0,1,2,3,4,5,6,7。
在第三次查询中,我们需要序列 1,10,3,4,2 的所有 Kheshtak,它们是:0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15。
在第五次查询中,我们需要序列 0 的所有 Kheshtak,即 0。
输入解题思路,AI测评打分。不知道怎么写?