Submission details
Task:Xor sum
Sender:francden
Submission time:2025-09-22 16:25:16 +0300
Language:Python3 (PyPy3)
Status:READY
Result:ACCEPTED
Test results
testverdicttime
#1ACCEPTED0.04 sdetails
#2ACCEPTED0.79 sdetails

Code

n,q = [int(x) for x in input().split()]
L = [int(x) for x in input().split()]

tree = [0 for i in range(n)]
tree+=L
for i in range (n-1,0,-1):
    tree[i]= tree[2*i]^tree[2*i+1]


def mini(a,b):
    a+=n
    b+=n
    xor = 0
    while (a<=b):
        if a%2 == 1:
            xor = xor ^tree[a]
            a+=1
        if b%2 == 0:
            xor = xor ^tree[b]
            b-=1
        a//=2
        b//=2
    return xor

def update(k,v):
    k = n + k
    tree[k] = v
    k//=2
    while(k>=1):
        
        tree[k] = tree[2*k]^tree[2*k+1]
        k//=2

for i in range (q):
    b,c = [int(x) for x in input().split()]
    
    print(mini(b-1,c-1))

Test details

Test 1

Verdict: ACCEPTED

input
8 36
7 6 4 6 2 9 4 8
1 1
1 2
1 3
...

correct output
7
1
5
3
1
...

user output
7
1
5
3
1
...

Test 2

Verdict: ACCEPTED

input
200000 200000
921726510 307633388 992247073 ...

correct output
834756431
130379787
403037296
308618218
784778243
...

user output
834756431
130379787
403037296
308618218
784778243
...
Truncated