#P12827. 「DLESS-2」XOR and Even

    ID: 11799 远端评测题 1500ms 512MiB 尝试: 0 已通过: 0 难度: 8 上传者: 标签>O2优化数位 DP线性基洛谷比赛

「DLESS-2」XOR and Even

Description

You are given a sequence aa of nn non-negative integers. You need to process qq queries, each being one of the following two types:

  • 0 l r x: Count the number of ways to select an even number of elements from the range [l,r][l, r] (inclusive) such that their XOR sum is less than or equal to xx. Selecting zero elements is allowed, and their XOR sum is 00. Output the count modulo 109+710^9+7.
  • 1 l r x: Select an even number of elements from the range [l,r][l, r] (inclusive). Let their XOR sum be SS. Find the maximum possible value of SxS \oplus x.

Input Format

This problem contains multiple test cases. The first line contains an integer TT, the number of test cases.

For each test case: The first line contains two integers, nn and qq. The second line contains nn integers, representing the sequence aa. Each of the next qq lines describes a query in the format specified in the problem description.

Output Format

For each query, output a single integer on one line, representing the answer.

2
5 6
1 2 4 8 16
0 1 3 3
0 1 4 3
1 2 4 0
1 2 4 1
0 1 5 114514
0 1 4 5
6 7
1 1 4 5 1 4
0 1 3 0
1 2 4 0
1 1 2 1
1 2 6 0
1 1 4 5
0 2 4 4
1 1 2 0
2
2
12
13
16
3
2
5
1
5
5
3
0

Hint

For all test cases, it is guaranteed that:

  • 1T1041\le T\le 10^4
  • 1n,n5×1051\le n,\sum n\le 5\times10^5
  • 1q,q5×1051\le q,\sum q\le 5\times10^5
  • 1l<rn1\le l<r\le n
  • 0ai,x<2300\le a_i,x<2^{30}

This problem uses subtasks for scoring (bundled testing). The descriptions of the subtasks are as follows:

Subtask n\sum n\le q\sum q\le Special Property Score
11 1010 10001000 None 1010
22 10001000 A 1515
33 B
44 None 1010
55 5×1045\times10^4
66 5×1055\times10^5 A 1515
77 B
88 None 1010

Special Property A: All queries are of type 0.

Special Property B: All queries are of type 1.