Permutation Segments
You are given two positive integers $N$ and $K$. A [permutation](https://en.wikipedia.org/wiki/Permutation) $P_1, P_2, \dots, P_N$ of the first $N$ positive integers is *good* if the following statement holds: - Consider a set $S$ of segments, initially empty. For each $i$ ($1 \leq i \leq N-1$) such that $P_i \lt P_{i+1}$, insert the segment $[P_i, P_{i+1}]$ into $S$. Then, if you pick any subse
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