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:

  1. given numbers l, r and k, Malek should perform for each l ≤ i ≤ r (, bitwise exclusive OR of numbers a and b).
  2. 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.

达芙是安达尔兹古国的女王,她是一名竞技编程爱好者。因此,当她看到自己的大臣马莱克空闲时,便给了他一个由 nn 个非负整数组成的序列 a1,a2,…,ana_1, a_2, \dots, a_n,并要求他对该序列执行 qq 个查询。

查询分为两类:

  1. 给定数字 ll、rr 和 kk,马莱克应对每个满足 l≤i≤rl \le i \le r 的下标 ii 执行操作:ai←ai⊕ka_i \gets a_i \oplus k(其中 ⊕\oplus 表示 aa 与 bb 的按位异或运算)。
  2. 给定数字 ll 和 rr,马莱克需报告子序列 al,al+1,…,ara_l, a_{l+1}, \dots, a_r 的“得分”。

序列 b1,…,bkb_1, \dots, b_k 的得分为其不同的“赫什塔克”(Kheshtak)的个数。一个非负整数 ww 是该序列的一个赫什塔克,当且仅当存在 bb 的一个子序列(记为 bi1,bi2,…,bixb_{i_1}, b_{i_2}, \dots, b_{i_x},允许为空),使得

w=bi1⊕bi2⊕⋯⊕bixw = b_{i_1} \oplus b_{i_2} \oplus \dots \oplus b_{i_x}

(其中 1≤i1<i2<⋯<ix≤k1 \le i_1 < i_2 < \dots < i_x \le k)。若该子序列为空,则 w=0w = 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)

输入的第一行包含两个整数 nn 和 qq(1≤n≤2×1051 \leq n \leq 2 \times 10^5,1≤q≤4×1041 \leq q \leq 4 \times 10^4)。

输入的第二行包含 nn 个整数 a1, a2, …, ana_1,\,a_2,\,\dots,\,a_n,以空格分隔(对每个 1≤i≤n1 \leq i \leq n,满足 0≤ai≤1090 \leq a_i \leq 10^9)。

接下来的 qq 行表示查询。每行以一个整数 tt(1≤t≤21 \leq t \leq 2)开头,表示对应查询的类型。若 t=1t = 1,则该行还包含另外三个整数 ll、rr 和 kk;否则该行还包含另外两个整数 ll 和 rr。(满足 1≤l≤r≤n1 \leq l \leq r \leq n,且 0≤k≤1090 \leq k \leq 10^9)

输出格式

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, 21,\,2,\,3,\,4,\,2 的所有 Kheshtak,它们是:0, 1, 2, 3, 4, 5, 6, 70,\,1,\,2,\,3,\,4,\,5,\,6,\,7。

在第三次查询中,我们需要序列 1, 10, 3, 4, 21,\,10,\,3,\,4,\,2 的所有 Kheshtak,它们是:0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 150,\,1,\,2,\,3,\,4,\,5,\,6,\,7,\,8,\,9,\,10,\,11,\,12,\,13,\,14,\,15。

在第五次查询中,我们需要序列 00 的所有 Kheshtak,即 00。

输入解题思路,AI测评打分。不知道怎么写?

首页