算竞笔记 - 线段树专题

注: segment_tree 均采用 1-Index 访问; segment_tree::reset(vector&) 中vector为0-Index 242E. XOR on Segment 区间二进制改+lazy传递+二进制trick You’ve got an array $a$, consisting of $n$ integers $a_1, a_2, …, a_n$. You are allowed to perform two operations on this array: Calculate the sum of current array elements on the segment $[l,r]$, that is, count value $a_l + a_{l+1} + … + a_{r}$ Apply the xor operation with a given number x to each array element on the segment $[l,r]$, that is, execute $a_l = a_l \oplus x, a_{l+1} = a_{l+1} \oplus x,…,a_r = a_r \oplus x$ This operation changes exactly $r - l + 1$ array elements....

December 26, 2024 · 16 min · 3363 words · mos9527