← All problemsSign in

Permutation Xor

CodeChefRating 2985Open on judge ↗

A sequence of $N$ integers is called a permutation if it contains all integers from $1$ to $N$ exactly once. For a permutation $P$ of length $N$ (where $N$ is an **even integer**), we define the function $F(P)$ as: $F(P) = $ $(P_1 \oplus P_2) + (P_3 \oplus P_4) + \ldots + (P_{n-1} \oplus P_n)$. Here, $\oplus$ denotes the [bitwise XOR operation](https://en.wikipedia.org/wiki/Bitwise_operation

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