#P6225. [eJOI 2019] 异或橙子
[eJOI 2019] 异或橙子
Problem Description
Janez likes oranges. He built an orange scanner, but for each scanned orange, the image output can only be a -bit integer.
He scanned a total of oranges, but sometimes he rescans an orange, causing the -bit integer of that orange to be updated.
Janez wants to analyze these oranges. He finds the XOR operation very interesting. Each time he chooses an interval from to , and he wants to get the XOR of the XOR sums of all subintervals within this interval.
For example, when , let the integer of the -th orange in the orange sequence be . Then what he asks for is:
$$a_2 \oplus a_3 \oplus a_4 \oplus (a_2\oplus a_3)\oplus(a_3\oplus a_4)\oplus(a_2\oplus a_3 \oplus a_4)$$Note: in the expression represents the bitwise XOR operation. The XOR rules are as follows.
For the -th bit of two numbers, denoted by , we have:
Example:
Input Format
The first line contains two positive integers , representing the number of oranges and the number of operations.
The next line contains non-negative integers, representing the value obtained by scanning each orange, indexed starting from .
The next lines each contain three numbers:
-
If the first number is , then a positive integer and a non-negative integer follow, meaning to modify the scanned value of the -th orange to .
-
If the first number is , then two positive integers follow, meaning to query the answer for this interval.
Output Format
For each query, output one non-negative integer per line, representing the required total XOR sum.
3 3
1 2 3
2 1 3
1 1 3
2 1 3
2
0
5 6
1 2 3 4 5
2 1 3
1 1 3
2 1 5
2 4 4
1 1 1
2 4 4
2
5
4
4
Hint
Explanation of Sample Input/Output 1
-
Initially, , and the query result is $1\oplus 2\oplus 3\oplus(1\oplus 2)\oplus (2\oplus 3)\oplus(1\oplus 2\oplus 3)=2$.
-
After the modification, the first position is changed to , and the query result is $3\oplus 2\oplus 3\oplus(3\oplus 2)\oplus (2\oplus 3)\oplus(3\oplus 2\oplus 3)=0$.
Constraints
This problem uses bundled testdata with a total of 5 subtasks.
- Subtask 1 (12 points): , no special restrictions.
- Subtask 2 (18 points): , and there are no update operations.
- Subtask 3 (25 points): , no special restrictions.
- Subtask 4 (20 points): , and there are no update operations.
- Subtask 5 (25 points): , no special restrictions.
For all testdata, .
Notes
Original problem: eJOI2019 Problem A. XORanges
Statement and data source: LibreOJ
Translated by ChatGPT 5