GUPTA MECHANICAL

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

Wednesday, 13 July 2022

[Solution] The XOR-OR Dilemma CodeChef Solution


Chef has an array A of length N such that Ai=i.

In one operation, Chef can pick any two elements of the array, delete them from A, and append either their bitwise XOR or their bitwise OR to A.

Note that after each operation, the length of the array decreases by 1.

Let F be the final number obtained after N1 operations are made. You are given an integer X, determine if you can get F=X via some sequence of operations.

In case it is possible to get F=X, print the operations too (see the section Output format for more

Solution Click Below:-  👉CLICK HERE👈
👇👇👇👇👇

 details), otherwise print 1.

Input Format

  • The first line of input will contain a single integer T, denoting the number of test cases.

  • Each test case consists of a single line containing two space-separated integers N and X.

Output Format

For each test case, output 1 if it is impossible to get X in the end. Otherwise print N1 lines denoting the operations.

On each line, print

  • 1 x y if you want replace x and y with x OR y.
  • 2 x y if you want replace x and y with x XOR y.

Note that x and y are the elements of the array at the time of applying the operation, and if either of them is not present in the array you will receive a WA verdict.

Constraints

  • 1T5000
  • 2N215
  • 1X2161
  • The sum of N over all test cases won't exceed 

No comments:

Post a Comment