#abc223h. H - Xor Query

H - Xor Query

Score : 600600 points

问题描述

给定一个包含 NN 个正整数的序列 A=(A1,,AN)A = (A_1, \dots, A_N)

处理 QQ 个查询。在第 ii1iQ1 \leq i \leq Q)个查询中,判断是否可以从 ALi,ALi+1,,ARiA_{L_i}, A_{L_i + 1}, \dots, A_{R_i} 中选择一个或多个元素,使得它们的按位异或值为 XiX_i

什么是按位异或(XOR\mathrm{XOR})?

对于整数 AABB 的按位异或运算 A XOR BA\ \mathrm{XOR}\ B 定义如下:

  • A XOR BA\ \mathrm{XOR}\ B 以二进制表示时,位于 2k2^k 位(k0k \geq 0)上的数字是 11,当且仅当 AABB 中恰好有一个是 11;否则为 00

例如,我们有 3 XOR 5=63\ \mathrm{XOR}\ 5 = 6(以二进制表示:011 XOR 101=110011\ \mathrm{XOR}\ 101 = 110)。

以上为通义千问 qwen-max 翻译,仅供参考。

Problem Statement

Given is a sequence of NN positive integers A=(A1,,AN)A = (A_1, \dots, A_N).

Process QQ queries. In the ii-th query (1iQ)(1 \leq i \leq Q), determine whether it is possible to choose one or more elements from ALi,ALi+1,,ARiA_{L_i}, A_{L_i + 1}, \dots, A_{R_i} so that their XOR\mathrm{XOR} is XiX_i.

What is XOR\mathrm{XOR}?

The bitwise XOR\mathrm{XOR} of integers AA and BB, A XOR BA\ \mathrm{XOR}\ B, is defined as follows:

  • When A XOR BA\ \mathrm{XOR}\ B is written in base two, the digit in the 2k2^k's place (k0k \geq 0) is 11 if exactly one of AA and BB is 11, and 00 otherwise.

For example, we have 3 XOR 5=63\ \mathrm{XOR}\ 5 = 6 (in base two: 011 XOR 101=110011\ \mathrm{XOR}\ 101 = 110).

Constraints

  • 1N4×1051 \leq N \leq 4 \times 10^5
  • 1Q2×1051 \leq Q \leq 2 \times 10^5
  • 1Ai<2601 \leq A_i \lt 2^{60}
  • 1LiRiN1 \leq L_i \leq R_i \leq N
  • 1Xi<2601 \leq X_i \lt 2^{60}
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

NN QQ

A1A_1 \ldots ANA_N

L1L_1 R1R_1 X1X_1

\vdots

LQL_Q RQR_Q XQX_Q

Output

Print QQ lines. The ii-th line (1iQ)(1 \leq i \leq Q) should contain Yes if it is possible to choose one or more elements from ALi,ALi+1,,ARiA_{L_i}, A_{L_i + 1}, \dots, A_{R_i} so that their XOR\mathrm{XOR} is XiX_i, and No otherwise.

Sample Input 1

5 2
3 1 4 1 5
1 3 7
2 5 7

Sample Output 1

Yes
No

In the first query, you can choose A1A_1 and A3A_3, whose XOR\mathrm{XOR} is 77.

In the second query, there is no way to choose elements so that their XOR\mathrm{XOR} is 77.

Sample Input 2

10 10
8 45 56 9 38 28 33 5 15 19
10 10 53
3 8 60
1 10 29
5 7 62
3 7 51
8 8 52
1 4 60
6 8 32
4 8 58
5 9 2

Sample Output 2

No
No
Yes
No
Yes
No
No
No
Yes
Yes

update @ 2024/3/10 09:50:27