#P10009. [集训队互测 2022] 线段树
[集训队互测 2022] 线段树
Background
Please note: this problem is not a segment tree template problem.
Problem Description
You are given a sequence of length . You need to perform a total of operations of the following two types:
-
1 l r: Replace with its XOR difference. Formally, let (), and then for each , replace with . -
2 pos: Query the value of .
After all operations are completed, you also need to output the final sequence .
Input Format
The first line contains an integer , indicating that the input satisfies the constraints of the -th subtask.
The second line contains two integers , representing the length of the sequence and the number of operations.
The third line contains integers .
In the next lines, each line contains several numbers describing one operation. If it is the first type of operation, the line contains three numbers 1 l r. If it is the second type of operation, the line contains two numbers 2 pos.
Output Format
Suppose there are operations of the second type. Output a total of lines.
In the first lines, output one integer per line, which is the answer to that query.
In the next lines, output one integer per line, which is the final sequence .
1
6 6
1 1 5 1 9 4
2 5
1 2 5
2 4
1 3 6
2 6
1 1 6
9
4
12
1
0
5
4
12
0
Hint
More samples can be found in the attached file. For the -th sample, .
Sample 1 Explanation
Initially, .
The first operation asks to output . At this time, , so output .
The second operation asks to replace with its XOR difference. is , and its XOR difference is . Therefore, after this operation, the sequence becomes .
The third operation asks to output . At this time, , so output .
The fourth operation asks to replace with its XOR difference. is , and its XOR difference is . Therefore, after this operation, the sequence becomes .
The fifth operation asks to output . At this time, , so output .
The sixth operation asks to replace with its XOR difference. is , and its XOR difference is . Therefore, after this operation, the sequence becomes .
The final sequence is .
Constraints and Notes
For all testdata, it is guaranteed that , , , , and .
| Subtask ID | Special Property | Score | Subtask Dependencies | ||
|---|---|---|---|---|---|
| None | None | ||||
| A | |||||
| B | |||||
| CD | |||||
| DE | |||||
| D | |||||
| E | |||||
| None | |||||
Special Property A: .
Special Property B: .
Special Property C: Let be the number of non-zero positions in the sequence . Then .
Special Property D: For operation , it holds that and .
Special Property E: There is no operation .
Translated by ChatGPT 5