#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 3232-bit integer.

He scanned a total of nn oranges, but sometimes he rescans an orange, causing the 3232-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 ll to uu, and he wants to get the XOR of the XOR sums of all subintervals within this interval.

For example, when l=2,u=4l=2,u=4, let the integer of the ii-th orange in the orange sequence AA be aia_i. 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: \oplus in the expression represents the bitwise XOR operation. The XOR rules are as follows.

For the ii-th bit of two numbers, denoted by x,yx,y, we have:

xx yy xyx\oplus y
00 11 11
11 00
00 00
11

Example: 1323=2613\oplus 23=26

13=13= 00011010\cdots 001101
23=23= 00101110\cdots 010111
1323=13\oplus 23= 00110100\cdots 011010

Input Format

The first line contains two positive integers n,qn,q, representing the number of oranges and the number of operations.

The next line contains nn non-negative integers, representing the value obtained by scanning each orange, indexed starting from 11.

The next qq lines each contain three numbers:

  • If the first number is 11, then a positive integer ii and a non-negative integer jj follow, meaning to modify the scanned value aia_i of the ii-th orange to jj.

  • If the first number is 22, then two positive integers u,lu,l 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, A=[1,2,3]A=[1,2,3], 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 33, 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): 1n,q1021\le n,q\le 10^2, no special restrictions.
  • Subtask 2 (18 points): 1n,q5×1021\le n,q\le 5\times 10^2, and there are no update operations.
  • Subtask 3 (25 points): 1n,q5×1031\le n,q\le 5\times 10^3, no special restrictions.
  • Subtask 4 (20 points): 1n,q2×1051\le n,q\le 2\times 10^5, and there are no update operations.
  • Subtask 5 (25 points): 1n,q2×1051\le n,q\le 2\times 10^5, no special restrictions.

For all testdata, 0ai109,1n,q2×1050\le a_i\le 10^9,1\le n,q\le 2\times 10^5.


Notes

Original problem: eJOI2019 Problem A. XORanges

Statement and data source: LibreOJ

Translated by ChatGPT 5