luogu#P11071. 「QMSOI R1」 Distorted Fate
「QMSOI R1」 Distorted Fate
Background
O Fortuna velut luna statu variabilis……
(Image from Phigros artwork. Please contact for removal if needed.)
Enhanced version of T512613.
Problem Description
Geopelia needs to capture a special kind of gravitational wave, different from a black hole.
The -th gravitational wave has a frequency . Multiple gravitational waves will affect each other and stack together, forming a gravitational wave with a faster frequency.
Specifically, for a sequence of length , the frequency after stacking all gravitational waves in is , where denotes bitwise OR.
Now, Geopelia needs to know the sum of frequencies of several intervals that start from the same gravitational wave.
That is, Geopelia asks you for the value of:
where is the sequence formed by .
Unfortunately, due to the gravitational influence of the Azure Boundary, in some interval , the frequencies of all gravitational waves might be XORed with a value .
Geopelia wants to update her data in real time. Can you help her?
She knows the frequencies may be very large, so you only need to tell her the answer .
Formal Statement
Given an array of length , you need to perform the following operations.
-
1 l r xXOR with for all . -
2 l rCompute:
where denotes bitwise OR.
Input Format
The first line contains two integers and , representing the number of gravitational waves and the number of operations.
The second line contains integers. The -th integer is the initial frequency of gravitational wave .
Then follow lines. Each line contains three integers .
If , an additional integer is given, meaning to XOR the frequencies in interval with .
If , it means this is a query.
Output Format
For each query, output one integer per line, representing the result of the expression .
3 3
1 2 3
2 1 3
1 1 2 2
2 1 3
7
9
Hint
Sample Explanation
For the first query: at this time , so the answer is .
For the second query: at this time , so the answer is .
Constraints
This problem uses bundled testing with subtasks. The score for each subtask is as follows:
| Subtask | Time | Memory | Score | ||
|---|---|---|---|---|---|
For all testdata, , .
INITALIZING……
SCANING……
CONNECTING……__PhigrOS Client Login
TIME_OUT!
CONNECTING……__Unknown
SUCCESS!
————————
……Nine……Bird……
……Dove……!
……Hello?
…Can you hear me?
Dove?![SIGNAL LOST]
Translated by ChatGPT 5