P14359 [CSP-J 2025] XOR Sum
Description
Little R has a sequence of $n$ non-negative integers $a_1, a_2, \dots, a_n$. The weight of an interval $[l, r]$ ($1 \leq l \leq r \leq n$) is defined as the bitwise XOR sum of $a_l, a_{l+1}, \dots, a_r$ in binary, that is, $a_l \oplus a_{l+1} \oplus \dots \oplus a_r$, where $\oplus$ denotes the bitwise XOR operation.
Little X gives Little R a non-negative integer $k$. Little X wants Little R to choose as many **non-overlapping** intervals in the sequence as possible, so that the weight of every chosen interval is exactly $k$. Two intervals $[l_1, r_1], [l_2, r_2]$ intersect if and only if they contain at least one common index, that is, there exists $1 \leq i \leq n$ such that $l_1 \leq i \leq r_1$ and $l_2 \leq i \leq r_2$.
For example, for the sequence $[2, 1, 0, 3]$, if $k = 2$, Little R can choose the interval $[1, 1]$ and the interval $[2, 4]$, whose weights are $2$ and $1 \oplus 0 \oplus 3 = 2$ respectively; if $k = 3$, Little R can choose the interval $[1, 2]$ and the interval $[4, 4]$, whose weights are $1 \oplus 2 = 3$ and $3$ respectively.
You need to help Little R find the maximum number of intervals he can choose.
Input Format
The first line of input contains two non-negative integers $n, k$, representing the length of Little R's sequence and the non-negative integer Little X gives to Little R, respectively.
The second line of input contains $n$ non-negative integers $a_1, a_2, \dots, a_n$, representing Little R's sequence.
Output Format
Output one non-negative integer on a single line, representing the maximum number of intervals Little R can choose.
Explanation/Hint
### Example 1 Explanation
Little R can choose the interval $[1, 1]$ and the interval $[2, 4]$, whose XOR sums are $2$ and $1 \oplus 0 \oplus 3 = 2$ respectively. It can be proven that the maximum number of intervals Little R can choose is $2$.
### Example 2 Explanation
Little R can choose the interval $[1, 2]$ and the interval $[4, 4]$, whose XOR sums are $1 \oplus 2 = 3$ and $3$ respectively. It can be proven that the maximum number of intervals Little R can choose is $2$.
### Example 3 Explanation
Little R can choose the interval $[3, 3]$, whose XOR sum is $0$. It can be proven that the maximum number of intervals Little R can choose is $1$. Note that Little R cannot choose both the interval $[3, 3]$ and the interval $[1, 4]$, because these two intervals both contain the index $3$.
### Example 4
See $\textbf{\textit{xor/xor4.in}}$ and $\textbf{\textit{xor/xor4.ans}}$ in the contestant directory.
This example satisfies the constraints of test points $4, 5$.
### Example 5
See $\textbf{\textit{xor/xor5.in}}$ and $\textbf{\textit{xor/xor5.ans}}$ in the contestant directory.
This example satisfies the constraints of test points $9, 10$.
### Example 6
See $\textbf{\textit{xor/xor6.in}}$ and $\textbf{\textit{xor/xor6.ans}}$ in the contestant directory.
This example satisfies the constraints of test points $14, 15$.
### Constraints
For all test data, it is guaranteed that:
- $1 \leq n \leq 5 \times 10^5$, $0 \leq k < 2^{20}$;
- for all $1 \leq i \leq n$, $0 \leq a_i < 2^{20}$.
::cute-table{tuack}
| Test point | $n \leq$ | $k$ | Special property |
| :--: | :--: | :--: | :--: |
| $1$ | $2$ | $=0$ | A |
| $2$ | $10$ | $\leq 1$ | B |
| $3$ | $10^2$ | $=0$ | A |
| $4, 5$ | ^ | $\leq 1$ | B |
| $6 \sim 8$ | ^ | $\leq 255$ | C |
| $9, 10$ | $10^3$ | ^ | ^ |
| $11, 12$ | ^ | $< 2^{20}$ | None |
| $13$ | $2 \times 10^5$ | $\leq 1$ | B |
| $14, 15$ | ^ | $\leq 255$ | C |
| $16$ | ^ | $< 2^{20}$ | None |
| $17$ | $5 \times 10^5$ | $\leq 255$ | C |
| $18 \sim 20$ | ^ | $< 2^{20}$ | None |
Special property A: for all $1 \leq i \leq n$, $a_i = 1$.
Special property B: for all $1 \leq i \leq n$, $0 \leq a_i \leq 1$.
Special property C: for all $1 \leq i \leq n$, $0 \leq a_i \leq 255$.
Translated by QwenWork