Good Permutation
A permutation $P$ of length $N$ ($1$-based) is called good if it satisfies the following these conditions: - For each $1 \le i \le N$, $P_i \neq i$ - $|P_1 - 1| \oplus |P_2 - 2| \oplus \ldots \oplus |P_N - N| = 0$ Here, $\oplus$ denotes the [bitwise XOR operation](https://en.wikipedia.org/wiki/Bitwise_operation#XOR) and $|X|$ denotes the absolute value of $X$. Find any good permutation $P$ of le
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