Official algorithmic problem description and constraints.
You are given an integer N.
Find a permutation †P of the integers 1 to N such that Pi≥(Pi+1−Pi−1)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.
Detailed video explanations, mathematical intuition, and clean C++ implementation code.