← All problemsSign in

Strict Permutation

CodeChefRating 2155Open on judge ↗

You are given an integer $N$. You have to find a [permutation](https://en.wikipedia.org/wiki/Permutation) $P$ of the integers $\{1, 2, \ldots, N\}$ that satisfies $M$ conditions of the following form: - $(X_i, Y_i)$, denoting that the element $X_i\;(1\leq X_i \leq N)$ must appear in the prefix of length $Y_i$. Formally, if the index of the element $X_i$ is $K_i$ (i.e, $P_{K_i} = X_i$), then the co

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