[Solution] Xor Permutation CodeChef Solution
Chef has received a challenge for which he needs your help.
Given , find a permutation of numbers such that:
- . Here denotes the bitwise XOR operation.
If multiple such permutations exist, print any. If no such permutation exists, print .
Note that, a permutation of length is a sequence of integers such that every integer from to (inclusive) appears in it exactly once. For example, is a permutation of length while is not.
Input Format
- First line will contain , number of test cases. Then the test cases follow.
- Each test case contains of a single integer as input, - the length of the required permutation.
Enough Space CodeChef Solution
Chef Drinks Tea CodeChef Solution
High Accuracy CodeChef Solution
Xor Permutation CodeChef Solution
Permutation And Median CodeChef Solution
Segmentation Fault CodeChef Solution
Output Format
For each test case, output in a new line, space-separated integers, denoting a permutation satisfying the condition.
If multiple such permutations exist, print any. If no such permutation exists, print .
Constraints
- Sum of over all test cases does not exceed
No comments:
Post a Comment