#P7096. Dreams of Lawa
Dreams of Lawa
Dreams of Lawa
In the mystical land of Mosuo where legends tell of a lake called Lugu, TeaTea embarks on a surreal quest within Lugu Lake to find her elusive dream. Her n dreams are arranged in a sequence, each representing a Lawa with a non-negative beauty score ai. To distinguish these Lawa, TeaTea assigns the i-th Lawa from the left a beauty score of ai (a non-negative integer).
TeaTea will perform m operations. In each operation, she is given two numbers, p and x. She applies a bitwise XOR with x to both ap and ap+1 (i.e. she sets ap = ap \oplus x and ap+1 = ap+1 \oplus x, where \(\oplus\) denotes the bitwise XOR operation, equivalent to C++'s ^
operator).
After each operation, TeaTea wants to determine how many subarrays (contiguous intervals) \([l,r]\) with \(l \le r\) have an XOR sum equal to zero. The XOR sum of a subarray \([l,r]\) is given by
\[a_l \oplus a_{l+1} \oplus \dots \oplus a_r\]
Two subarrays are considered different if their endpoints differ.
To avoid large outputs, instead of printing the answer for each operation, output four integers:
- The bitwise XOR of all the answers.
- The count of answers that are odd.
- The maximum answer among all operations.
- The minimum answer among all operations.
Note: All formulas are represented in LaTeX format.
inputFormat
The first line contains two integers \(n\) and \(m\) \((1 \leq n, m \leq \text{small limits})\), representing the number of dreams and the number of operations respectively.
The second line contains \(n\) non-negative integers \(a_1, a_2, \dots, a_n\) representing the beauty scores of the dreams.
Each of the following \(m\) lines contains two integers \(p\) and \(x\) \((1 \leq p < n,\; 0 \leq x \leq \text{some limit})\), describing an operation where both \(a_p\) and \(a_{p+1}\) are updated as \(a_p = a_p \oplus x\) and \(a_{p+1} = a_{p+1} \oplus x\).
outputFormat
Output four integers separated by spaces:
- The XOR of all the answers obtained after each operation.
- The total number of answers that are odd.
- The maximum answer among all operations.
- The minimum answer among all operations.
sample
3 2
1 2 3
1 1
2 2
0 2 3 3