Sorting Vases
Chef has $N$ vases in a row (numbered $1$ through $N$, initially from left to right). He wants to sort them in a particular order which he finds the most beautiful. You are given a permutation $p_1, p_2, \ldots, p_N$ of the integers $1$ through $N$; for each valid $i$, Chef wants the $i$-th vase to end up as the $p_i$-th vase from the left. In order to achieve this, Chef can swap vases. Any two
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