GUPTA MECHANICAL

IN THIS WEBSITE I CAN TELL ALL ABOUT TECH. TIPS AND TRICKS APP REVIEWS AND UNBOXINGS ALSO TECH. NEWS .............

Wednesday 15 June 2022

[Solution] Permutation AND CodeChef Solution | CodeChef Problem Solution 2022


Chef's last task in his internship requires him to construct 2 permutations, each having length N, such that the bitwise AND of each pair of elements at every index is the same.

Formally, if the permutations are A and B, then, the value Ai&Bi must be constant over all 1iN.

Help Chef by providing him 2 such permutations. If it is not possible to construct such permutations, print 1 instead.

Input Format

  • First line will contain T, number of test cases. Then the test cases follow.
Solution Click Below:-  CLICK HERE


  • Each test case contains of a single line of input, a single integer N denoting the size of the required permutations.

Output Format

  • If there are valid permutations that satisfy the required condition, then:
    • In the first line, output N space-separated integers denoting the permutation A.
    • In the second line, output N space-separated integers denoting the permutation B.

  • If there is no valid pair of permutations, print -1 in a single line.

Constraints

  • 1T1000
  • 1N105
  • Sum of N over all test cases does not exceed 2105

No comments:

Post a Comment