XOR on Segment
HardRating 2000CodeforcesSegment Tree & Fenwick Tree
Approach hintTry it first, then revealHide
Store in every node how many elements have each of the 20 bits set. XOR with x on a range flips bit b everywhere, so cnt[b] becomes len - cnt[b]; this works as a lazy tag, and sums follow from the bit counts.