You are given an array of size \(n\). Initially, all the elements are zero. You are provided with \(q\) queries and each query is one of the following types:
- \(1\ L\ R\ X\): For each element in the range \([L, R]\) such as \(y\), set \(y = y | X\).
- \(2\ L\ R\ X\): For each element in the range \([L, R]\) like $$y$$, set \(y = y \And X\).
- \(3\ L\ R\ X\): For each element in the range \([L, R]\) like $$y$$, set \(y = y \oplus X\).
- \(4\ L\ R\): Print the sum of the elements in range \([L, R]\).
- \(5\ L\ R\): Print the XOR of the elements in range \([L, R]\).
Input format
- First line: \(n\) and \(q\)
- Each of the next \(n\) lines: A query
Output format
For each query of type 4 or 5, print the answer.
Constraints
\(1 \le n,\ q,\ X \le 2 \times 10^5\\ 1 \le L \le R \le n\)
Here is the array after each query:
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 9 9 9 9 0 0 0 0
0 0 9 9 9 9 0 0 0 0
0 0 9 9 9 9 0 0 0 0
0 0 9 9 9 9 0 0 0 0
0 0 1 1 1 1 8 0 0 0
0 0 1 1 1 1 8 0 0 0
0 0 1 1 1 1 0 0 0 0
0 0 1 1 1 1 0 0 0 0
0 0 1 1 1 1 0 0 0 0
0 0 1 1 1 1 0 0 0 0
0 0 1 1 1 1 0 0 7 0
4 4 5 5 5 5 4 0 7 0
4 4 5 5 5 5 4 0 7 0
4 5 4 4 4 4 5 1 6 0
4 5 4 4 4 12 13 9 14 0
4 5 4 4 4 12 13 9 14 0
2 3 2 2 2 10 11 9 14 0
2 3 2 2 2 10 11 9 14 0
Please login to use the editor
You need to be logged in to access the code editor
Loading...
Please wait while we load the editor
Login to unlock the editorial
Please login to use the editor
You need to be logged in to access the code editor
Loading...
Please wait while we load the editor