#P7096. [yLOI2020] 泸沽寻梦
[yLOI2020] 泸沽寻梦
Description
To the south there is a land of immortals, called Mosuo; in Mosuo there is a lake, and it is Lugu.
Chacha is searching for her dream in Lugu Lake. In the hazy mist, Chacha’s dreams are arranged into a sequence. All of Chacha’s dreams look like “Lawa” (Lawa). To distinguish these Lawa, Chacha defines that the “beauty value” of the -th Lawa from left to right is a non-negative integer . Facing these dreams, Chacha will perform operations. Each operation gives two numbers , and then applies bitwise XOR with to both and . After each operation, Chacha wants to know: in the current dream sequence, how many subsegments satisfy and have XOR sum equal to . Please answer Chacha’s question.
The XOR sum of segment is defined as $a_l \otimes a_{l + 1} \otimes \dots a_{r - 1} \otimes a_r$, where denotes the binary bitwise XOR operation, i.e. the “^” operator in C++. Two segments are different if and only if their left endpoints are different, or their right endpoints are different, or both are different.
To avoid overly large output, you only need to output four integers: the bitwise XOR of all your answers, the number of times your answer is odd, the maximum among all your answers, and the minimum among all your answers.
Input Format
The first line contains two integers, representing the number of dreams and the number of operations .
The second line contains space-separated integers, where the -th integer is the beauty value of the -th Lawa.
The next lines each contain two integers, denoting the and of one operation in order.
Output Format
Output four lines, each containing one integer, in order: the bitwise XOR of all your answers, the number of times your answer is odd, the maximum among all your answers, and the minimum among all your answers.
5 3
1 2 3 4 5
1 3
2 3
3 3
3
3
3
1
Hint
Sample 1 Explanation
- After the first operation, the sequence becomes . There is exactly one segment whose XOR sum is , so the answer for this query is .
- After the second operation, the sequence becomes . The segments , , and have XOR sum , so the answer for this query is .
- After the third operation, the sequence becomes . There is exactly one segment whose XOR sum is , so the answer for this query is . The XOR of all answers is . There are times when the answer is odd. The maximum among all answers is , and the minimum is .
Constraints
This problem uses bundled subtasks, with 5 subtasks in total.
- Subtask ( points): .
- Subtask ( points): .
- Subtask ( points): .
- Subtask ( points): .
- Subtask ( points): no special restrictions.
For the first four subtasks, it is guaranteed that .
For all testdata, it is guaranteed that , , and .
Notes
- Note that does not imply .
- Note the impact of large input size on program efficiency.
- The special output format in this problem is only to avoid TLE due to overly large output, and is unrelated to the solution.
- Note the impact of constant factors on program efficiency.
- This problem provides two sample files; see dream.zip in the additional files.
Translated by ChatGPT 5
京公网安备 11011102002149号