← All problemsSign in

Restoration

CodeChefRating 2652Open on judge ↗

Chef has a hidden permutation $P$ of $N$ integers and challenges you to find $P$ using **at most** $N-1$ queries of the following kind: - Query: A permutation $Q$ of length $N$. - Response: Chef generates a permutation $\bar{P}$ defined as $\bar{P_i}=P_{Q_i}, 1\le i\le N$. Chef responds with all such indices where $P_i$ is the maximum element of the prefix of length $i$, i.e., Chef will respo

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