102237: [AtCoder]ABC223 H - Xor Query

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Score : $600$ points

Problem Statement

Given is a sequence of $N$ positive integers $A = (A_1, \dots, A_N)$.

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

What is $\mathrm{XOR}$?

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

  • When $A\ \mathrm{XOR}\ B$ is written in base two, the digit in the $2^k$'s place ($k \geq 0$) is $1$ if exactly one of $A$ and $B$ is $1$, and $0$ otherwise.
For example, we have $3\ \mathrm{XOR}\ 5 = 6$ (in base two: $011\ \mathrm{XOR}\ 101 = 110$).

Constraints

  • $1 \leq N \leq 4 \times 10^5$
  • $1 \leq Q \leq 2 \times 10^5$
  • $1 \leq A_i \lt 2^{60}$
  • $1 \leq L_i \leq R_i \leq N$
  • $1 \leq X_i \lt 2^{60}$
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

$N$ $Q$
$A_1$ $\ldots$ $A_N$
$L_1$ $R_1$ $X_1$
$\vdots$
$L_Q$ $R_Q$ $X_Q$

Output

Print $Q$ lines. The $i$-th line $(1 \leq i \leq Q)$ should contain Yes if it is possible to choose one or more elements from $A_{L_i}, A_{L_i + 1}, \dots, A_{R_i}$ so that their $\mathrm{XOR}$ is $X_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 $A_1$ and $A_3$, whose $\mathrm{XOR}$ is $7$.

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


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

Input

题意翻译

- 给定一个长度为 $N$ 正整数序列 $A$,$Q$ 次询问。 - 每次询问给出三个正整数 $L$、$R$、$X$,请你判断能否从原序列 $A_L$,$A_{L+1}$,... ,$A_R$ 中选出若干个数使其异或和为 $X$。

Output

得分:600分 部分 问题描述 给定一个由$N$个正整数组成的序列$A = (A_1, \dots, A_N)$。 处理$Q$个查询。在第$i$个查询$(1 \leq i \leq Q)$中,确定是否可以从$A_{L_i}, A_{L_i + 1}, \dots, A_{R_i}$中选择一个或多个元素,使它们的异或值为$X_i$。 详细信息 什么是异或? 整数$A$和$B$的按位异或运算$A\ \mathrm{XOR}\ B$定义如下: 当$A\ \mathrm{XOR}\ B$用二进制表示时,$2^k$位($k \geq 0$)上的数字为$1$,如果$A$和$B$中恰好有一个为$1$,否则为$0$。 例如,我们有$3\ \mathrm{XOR}\ 5 = 6$(用二进制表示:$011\ \mathrm{XOR}\ 101 = 110$)。 部分 约束条件 $1 \leq N \leq 4 \times 10^5$ $1 \leq Q \leq 2 \times 10^5$ $1 \leq A_i \lt 2^{60}$ $1 \leq L_i \leq R_i \leq N$ $1 \leq X_i \lt 2^{60}$ 输入中的所有值都是整数。 输入格式 输入通过标准输入给出,格式如下: $N$ $Q$ $A_1$ $\ldots$ $A_N$ $L_1$ $R_1$ $X_1$ $\vdots$ $L_Q$ $R_Q$ $X_Q$ 输出格式 输出$Q$行。第$i$行$(1 \leq i \leq Q)$应包含Yes,如果可以从$A_{L_i}, A_{L_i + 1}, \dots, A_{R_i}$中选择一个或多个元素,使它们的异或值为$X_i$,否则为No。 样例输入1 5 2 3 1 4 1 5 1 3 7 2 5 7 样例输出1 Yes No 在第一个查询中,您可以选择$A_1$和$A_3$,它们的异或值为$7$。 在第二个查询中,无法选择元素,使它们的异或值为$7$。 样例输入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 样例输出2 No No Yes No Yes No No No Yes Yes

加入题单

算法标签: