CF 1725F - Field Photography
Each row initially contains a contiguous block of contestants placed on an extremely large integer line of columns. Row $i$ occupies every position from $Li$ to $Ri$, so geometrically each row is just a closed interval.
Rating: 2100
Tags: bitmasks, data structures, sortings
Solve time: 2m 55s
Verified: no
Solution
Problem Understanding
Each row initially contains a contiguous block of contestants placed on an extremely large integer line of columns. Row $i$ occupies every position from $L_i$ to $R_i$, so geometrically each row is just a closed interval.
We are allowed to shift an entire row left or right by any positive integer $k$. Each such move adds $k$ into a global accumulator using bitwise OR. For a query value $W$, we must choose a seq