#C10220. XOR Array Reordering

    ID: 39402 Type: Default 1000ms 256MiB

XOR Array Reordering

XOR Array Reordering

You are given T test cases. For each test case, you are given an array of n integers representing item prices, an integer k, and a target value. Your task is to determine if there exists a contiguous segment of exactly k items in the current order whose bitwise XOR is equal to the target value.

Note: Although the title refers to "reordering", you are not allowed to change the order of the items. You just need to check if such a contiguous segment exists in the given sequence.

The bitwise XOR operation is defined as follows in \( \LaTeX \): \[ a \oplus b \] It takes two numbers and performs the XOR operation on every bit of the two numbers.

Example: If the input array is [1, 3, 5, 7] and k = 2 with target = 6, then the segment [3, 5] yields \(3 \oplus 5 = 6\), so the answer is YES.

inputFormat

The first line contains an integer T representing the number of test cases. For each test case, the first line contains three integers n, k, and target separated by spaces, where n is the number of items, k is the length of the contiguous segment, and target is the desired XOR value. The second line of each test case contains n integers representing the prices of the items, separated by spaces.

Constraints:

  • 1 \(\leq T \leq\) 100
  • 1 \(\leq n \leq\) 105
  • 1 \(\leq k \leq n\)
  • 0 \(\leq\) prices, target \(\leq 10^9\)

outputFormat

For each test case, output a single line containing either YES if there exists a contiguous segment of length k whose bitwise XOR equals the target, or NO otherwise.

## sample
3
4 2 6
1 3 5 7
5 3 14
2 4 6 8 10
3 1 2
1 2 3
YES

NO YES

</p>