TechInfo

Binary Queries CodeKaze June23 Round 2 Solution || India’s Biggest Hiring Challenge

Binary Queries CodeKaze June23 Round 2 Solution || India’s Biggest Hiring Challenge

Answers will be Uploaded Shortly and it will be Notified on Telegram, So JOIN NOW
JoinScishowEngineerTelegram

Binary Queries CodeKaze June23 Round 2 Solution || India’s Biggest Hiring Challenge

Problem Statement

You are given an array ‘A’ of length ‘N’. There are ‘Q’ queries.

A query is of the form ‘L, R, X’: First, replace ‘A[ i ]’ with ‘A[ i ] XOR X’ for all ‘i’ such that ‘L <= i <= R’. Then, the answer to the query is the bitwise OR of all ‘A[ i ]’ such that ‘L <= i <= R’.

Return an array ‘B’ of length ‘Q’ such that ‘B[ i ]’ is the answer to the ‘i-th’ query.

For Example :
Let 'N' = 3, 'A' = [ 9, 1, 3 ], 'Q' = 2, queries = [ [ 0, 2, 1 ], [ 0, 1, 4 ] ].
The first query changes 'A' to [ 8, 0, 2 ], and the answer to it is 'A[0] OR A[1] OR A[2] = 8 OR 0 OR 2 = 10'.
The second query changes 'A' to [ 12, 4, 2 ], and the answer to it is 'A[0] OR A[1] = 12 OR 4 = 12'.
Thus, the answer is [ 10, 12 ].
Detailed explanation ( Input/output format, Notes, Images )
Constraints :
1 <= 'T' <= 10
1 <= 'N, Q' <= 10^5
0 <= 'A[i], X' <= 10^9
0 <= 'L' <= 'R' < 'N'

Time Limit: 1 sec
Sample Input 1 :
2
4 2
1 2 10 6
1 3 3
0 2 6
3 2
3 3 3
0 2 0
0 2 3
Sample Output 1 :
13 15
3 0
Explanation Of Sample Input 1 :
First test case:-
The first query changes 'A' to [ 1, 1, 9, 5 ], and the answer to it is 'A[1] OR A[2] OR A[3] = 1 OR 9 OR 5 = 13'.
The second query changes 'A' to [ 7, 7, 15, 5 ], and the answer to it is 'A[0] OR A[1] OR A[2] = 7 OR 7 OR 15 = 15'.
Thus, the answer is [ 13, 15 ].

Second test case:-
The first query does not change 'A'. Since all the elements of 'A' are '3', the bitwise OR of any range is '3'.
The second query changes 'A' to [ 0, 0, 0 ], making the bitwise OR of any range '0'.
Thus, the answer is [ 3, 0 ].
Sample Input 2 :
2
4 2
1 2 3 4
0 3 101
0 2 65
5 3
101 19 69 111 37
0 3 8
2 4 10
0 4 1
Sample Output 2 :
103 39
127 111 126
Answers will be Uploaded Shortly and it will be Notified on Telegram, So JOIN NOW
JoinScishowEngineerTelegram


6 digit code appear after 69 seconds.
 

Wait for Solution


We are Still Solving…. Please Visit Our Social Media Handle Till Then

Here Discuss About Binary Queries CodeKaze June23 Round 2 Solution || India’s Biggest Hiring Challenge

Binary Queries CodeKaze June23 Round 2 Solution || India’s Biggest Hiring Challenge

 

Yhaa You have done it but next? if YOU Want to Get Others Please Visit Here ScishowEngineer   Then Follow US HERE and Join Telegram.

If You Want To Learn Something New Then Visit Our Official Channel YOUTUBE