#SGM0000036. XOR trên đoạn (XOR on Segment)
XOR trên đoạn (XOR on Segment)
XOR on Segment
Source: Codeforces
Version: Phuoc Hung OJ Extended
Problem Statement
Maintain an integer array under range-sum queries and range XOR updates by a common mask.
Input
The first line contains , the second the initial array, and the third . Each operation is:
1 l r: print the sum on .2 l r x: replace every in by .
Output
Print the sum for every type 1 query.
Subtasks
- 20 points: .
- 30 points: .
- 50 points: , , , .
Examples
Input
5
4 10 3 13 7
8
1 2 4
2 1 3 3
1 2 4
1 3 3
2 2 5 5
1 1 5
2 1 2 10
1 2 3
Output
26
22
0
34
11
Explanation
The first sum is . Each XOR update flips exactly the bit positions present in mask ; processing all operations yields the later sums 22, 0, 34, and 11.