GUPTA MECHANICAL

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

Sunday 19 June 2022

[Solution] The Lost Array CodeChef Solution | CodeChef Problem Solution 2022


JJ had an array A of length N such that 0Ai<230 for all 1iN.
He listed down the XOR of all the subsequences of A of size (N1) in some random order. Let's call the XOR of these (N+1) subsequences as B1,B2,,BN+1.

Unfortunately, he lost the initial array A. Can you help him recover it?

If there are multiple arrays which satisfy the given conditions, print any. Also, it is guaranteed that corresponding to the given input, an answer always exists.

Input Format

  • The first line will contain T - the number of test cases. Then the test cases follow.
  • The first line of each test case contains an integer N - the size of the initial array A.
  • The second line of each test case contains (N+1) integers B1,B2,,BN+1 - the XOR of all the
Solution Click Below:-  CLICK HERE

  •  subsequences of A of size (N1) in some random order.

Output Format

For each test case, output N integers A1,A2,,AN which satisfy the given conditions.








If multiple answers exist, print any.

Constraints

  • 1T105
  • 2N2105
  • 0Bi<230
  • Sum of N over all test cases does not exceed 

No comments:

Post a Comment