Costly Permutations
Every Christmas, Chef has a peculiar tradition of gifting a permutation $P$ of length $N$. For each index $i$ in the permutation $(1 \leq i \leq N)$, there is an associated value $V_i$. The value $V_i$ is the number of steps needed to return to index $i$ when following this path: - Start at index $i$. - Let the current index be $k$, then, move to the index $P_k$. - Continue until you return to in
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