311306: CF1968F. Equal XOR Segments
Description
Let us call an array $x_1,\dots,x_m$ interesting if it is possible to divide the array into $k>1$ parts so that bitwise XOR of values from each part are equal.
More formally, you must split array $x$ into $k$ consecutive segments, each element of $x$ must belong to exactly $1$ segment. Let $y_1,\dots,y_k$ be the XOR of elements from each part respectively. Then $y_1=y_2=\dots=y_k$ must be fulfilled.
For example, if $x = [1, 1, 2, 3, 0]$, you can split it as follows: $[\color{blue}1], [\color{green}1], [\color{red}2, \color{red}3, \color{red}0]$. Indeed $\color{blue}1=\color{green}1=\color{red}2 \oplus \color{red}3\oplus \color{red}0$.
You are given an array $a_1,\dots,a_n$. Your task is to answer $q$ queries:
- For fixed $l$, $r$, determine whether the subarray $a_l,a_{l+1},\dots,a_r$ is interesting.
The first line contains a single integer $t$ ($1\le t\le 10^4$) — the number of test cases.
The first line of each test case contains two integers $n$ and $q$ ($2 \le n \le 2 \cdot 10^5$, $1 \le q \le 2 \cdot 10^5$) — the number of elements in the array and the number of queries respectively.
The next line contains $n$ integers $a_1,\dots,a_n$ ($0 \le a_i < 2^{30}$) — elements of the array.
Each of the next $q$ lines contains two integers $l$ and $r$ ($1 \le l < r \le n$) describing the query.
It is guaranteed that the sum of $n$ over all testcases does not exceed $2 \cdot 10^5$.
It is guaranteed that the sum of $q$ over all testcases does not exceed $2 \cdot 10^5$.
OutputFor each query, output "YES" if the subarray is interesting and "NO" otherwise.
You can output "Yes" and "No" in any case (for example, the strings "yES", "yes", and "Yes" will be recognized as correct answers).
ExampleInput4 5 5 1 1 2 3 0 1 5 2 4 3 5 1 3 3 4 5 5 1 2 3 4 5 1 5 2 4 3 5 1 3 2 3 7 4 12 9 10 9 10 11 9 1 5 1 7 2 6 2 7 11 4 0 0 1 0 0 1 0 1 1 0 1 1 2 2 5 6 9 7 11Output
YES YES NO NO NO YES NO NO YES NO NO NO NO NO YES NO YES YESNote
Explanation for the first test case:
The first query is described in the statement.
In the second query, we should divide $[1,2,3]$. A possible division is $[1,2],[3]$, since $1\oplus 2=3$.
It can be shown that for queries $3,4,5$, the subarrays are not interesting.
Output
输入数据格式:
- 第一行一个整数t,表示测试用例的数量。
- 每个测试用例包含三行:
- 第一行两个整数n和q,分别表示数组长度和查询数量。
- 第二行n个整数,表示数组的元素。
- 接下来q行,每行两个整数l和r,表示一个查询的子数组范围。
输出数据格式:
- 对于每个查询,如果子数组是“有趣的”,输出"YES",否则输出"NO"。
请注意,题目中的数组索引从1开始。题目大意:判断一个数组是否可以分成k个连续的部分,使得每个部分的元素按位异或(XOR)的结果相等。 输入数据格式: - 第一行一个整数t,表示测试用例的数量。 - 每个测试用例包含三行: - 第一行两个整数n和q,分别表示数组长度和查询数量。 - 第二行n个整数,表示数组的元素。 - 接下来q行,每行两个整数l和r,表示一个查询的子数组范围。 输出数据格式: - 对于每个查询,如果子数组是“有趣的”,输出"YES",否则输出"NO"。 请注意,题目中的数组索引从1开始。