In an integer array (size 10^5) the operations are like these…
- Do bitwise xor operation with every element from index L to R by a particular number X
- Find the sum of the numbers from index L to R.
How can i do it with segment tree and lazy propagation ?
I’d keep, on each node, 32 integers telling me how many ones are there in each position of the binary representation of the child nodes.
To XOR a segment node, it’s just a matter of inverting how many ones are there in each position (for each bit 1 in X).
To calculate the sum,