← All problemsSign in

Compress all Subsegments

CodeChefRating 2724Open on judge ↗

For an array $B$, while it has more than one element, you can apply an operation on it - you choose any two elements $x,y$ (they may be the same value, but they should have different indices), delete them, and add an element $g(x, y)$ instead. Here $g(x, y)$ denotes the highest set bit in $x \oplus y$, or $0$ if they are equal. In other words, $g(x, y) = \max 2^k$, such that $2^k \leq (x \opl

HINT LADDERno hints yet
L1 Observation
L2 Technique
L3 Approach
L4 Pseudo-code
🔒
L5 Full solution
L5 unlocks only if you insist twice
solution.cppC++17

CodeSearch Tutor

Hints, not spoilers — it won’t hand over the full solution unless you insist.

voice by Sarvam AI

Sign in to chat with the tutor and save your progress.

Sign in to start