[Solution] Get Subscription solution codechef

Get Subscription solution codechef – Chef wants to conduct a lecture for which he needs to set up an online meeting of exactly XX minutes.

[Solution] Get Subscription solution codechef

The meeting platform supports a meeting of maximum 3030 minutes without subscription and a meeting of unlimited duration with subscription.

Determine whether Chef needs to take a subscription or not for setting up the meet.

Input Format

  • First line will contain TT, the number of test cases. Then the test cases follow.
  • First line of each test case contains an integer NN – denoting the length of array AA.
  • Second line contains NN integers A1,A2,ANA1,A2,…AN – denoting the array AA.

Output Format

For each test case, output the maximum XOR of all the elements of the updated array you can achieve.

[Solution] Get Subscription solution codechef

  • 1T1041≤T≤104
  • 2N21052≤N≤2⋅105
  • 0Ai<2300≤Ai<230
  • Sum of NN over all test cases do not exceed 21052⋅105

Sample Input 1 

2
4
3 3 3 3
3
1 6 4

Sample Output 1 

3
7

Get Subscription solution codechef

Test Case 11: We can choose the subarray [L,R][L,R] as [2,4][2,4] and X=0X=0. Thus, A2=3&0=0,A3=3&0=0,A2=3&0=0,A3=3&0=0, and A4=3&0=0A4=3&0=0. The updated array is [3,0,0,0][3,0,0,0]. The bitwise XOR of all the elements of the updated array is 3000=33⊕0⊕0⊕0=3.
It can be shown that the bitwise XOR of the updated array cannot exceed 33 after applying at most one operation.

Test Case 22: We can choose the subarray [L,R][L,R] as [1,2][1,2] and X=3X=3. Thus, A1=1&3=1A1=1&3=1 and A2=6&3=2A2=6&3=2. The updated array is [1,2,4][1,2,4]. The bitwise XOR of all the elements of the updated array is 124=71⊕2⊕4=7.
It can be shown that the bitwise XOR of the updated array cannot exceed 77 after applying at most one operation.

For Solution

Click here

Leave a Comment