← All problemsSign in

Permutation Construction

CodeChefRating 1389Open on judge ↗

You are given an integer $N$. Find a permutation$^\dagger$ $P$ of the integers $1$ to $N$ such that $$ P_i \geq \left( P_{i+1} - P_{i-1} \right)^2 $$ holds for *every* index $i$ from $2$ to $N-1$. It can be proved that at least one solution exists. If multiple solutions exist, print any of them. $^\dagger$ A permutation of the integers $1$ to $N$ is an array of length $N$ that contains eve

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