XOR and Parity

0

0 votes
Problem

You are given an array of n integers depending on which you have to answer q independent queries. The queries are of two types : 1 pos x that is you need to change the element present at position pos to x and 2 l r that is you need to tell the parity of the sum of

a) sum of all elements of the array between l to r

and

b) xor of all elements between l to r.

If the total sum comes out to be odd then print ODD and if even then print EVEN.

Input format :

The first line contains the number of test cases t. The description of the test cases follows. The first line contains a single integer n — the number of elements in the array. The second line contains n integers( the array elements). The next line conatins a single integer q(the number of queries) then follow q lines which is either of the form 1 pos x or 2 l r.

Output format :

For each query of type 2 you need to print "ODD" (without quotes) or "EVEN" (without quotes) depending on the parity of total sum of sum of all elements between l to r and xor of elements between l to r.

Constraints : 

1 <= t <= 103

1 <= n <= 105

1 <= a[i] <= 109  ( array elements)

1 <= q <=105

1 <= x <= 109

1 <= pos <= n

1 <= l <= r <= n

It is guaranteed that the sum of n and q does not exceed 105 over all test cases.

Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation

After the first query the element at pos 2 that is 2 changes to 7, so the array becomes : 1 7 3 4 5. Then for 2nd query we add all elements between pos 1 to 3 which are 1, 7, 3 which becomes 11 and takes their xor which becomes 5, now adding 11 and 5 we get 16 which is even so we prints EVEN.

Editor Image

?