XOR TEST
Practice
0 (0 votes)
Data structures
Medium
Approved
Recruit
Problem
67% Success 2015 Attempts 30 Points 1s Time Limit 256MB Memory 1024 KB Max Code

Given an integer array A of size N, you need to perform 2 operations over this array :

  1. \( 0\space L \space R \) : Find and print \( A[L]\) xor \(A[L+1]\) xor \(A[L+2]\) ... xor \(A[R]\)

  2. \( 1 \space X \space Y \) : Update the value of the \(X^{th}\) element of array A, i.e \(A[X]\) to \((A[X] \) XOR Y) . That is, after the update the value of the element shall be (\(A[X]\) XOR Y).

Can you do it ?

Input Format :

The first line contains a single integer N denoting the size of array A. The next line contains N space separated integers, where the \(i^{th}\) element denotes \(A[i]\). The third line contains the number of operations Q and then each of the remaining Q lines contain three space separated integers, where the \(i^{th}\) line denotes the parameters of the \(i^{th}\) query.

Output Format :

For each operation of the form \(0 \space L \space R\), display the answer for the operation in a separate line.

Input Constraints:

\( 1 \le N \le 10^6 \)

\( 1 \le Q \le 10^5 \)

\( 0 \le A[i] \le 10^6 \)

\( 1 \le L \le R \le N \)

\( 1 \le X \le N \)

\( 1 \le Y \le 10^6 \)

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Please wait while we load the editor

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:50
18 votes
Tags:
Data StructuresHardString ManipulationSuffix tree
Points:30
Tags:
MathematicsMediumBinary search algorithmFactorization
Points:50
8 votes
Tags:
Advanced Data StructuresData StructuresSegment Trees