Beauty of Segments
You are given $N$ segments $(l_1, r_1), (l_2, r_2), (l_N, r_N)$ and two integers $A$ and $B$. Let's define *playing a game* with two parameters $(x, y)$, where $0 \le x \le N$, as the following recursive process: - If $x = 0$, the game ends immediately. - Otherwise, if $y \le l_x$ or $r_x \le y$, end this game and play a game with $(x-1, y)$. - Otherwise (if $l_x \lt y \lt r_x$), you must choose o
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.
Sign in to chat with the tutor and save your progress.
Sign in to start