← All problemsSign in

Nic PRM

We call a permutation {p[1], p[2], ..., p[n]} of {1, 2, ..., n} nice if and only for all 1, there exists a j such that |p[i]-p[j]|=1. You have a permutation of {1, 2, ..., n}, which might or might not be nice. You have to find the smallest nice permutation which is not less than the given permutation. A permutation {p_1, p_2, ..., p_n} is said to be less than {q_1, q_2, ..., q_n} if p_i for the l

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