CSES - Aalto Competitive Programming 2024 - wk4 - Mon - Results
Submission details
Task:Xor sum
Sender:Mojojijo
Submission time:2024-09-23 16:50:18 +0300
Language:Python3 (PyPy3)
Status:READY
Result:ACCEPTED
Test results
testverdicttime
#1ACCEPTED0.04 sdetails
#2ACCEPTED0.44 sdetails

Code

def xor_sum(n,arr,barr):

    prefix_xor = [0] * (n + 1)
    for i in range(1, n + 1):
        prefix_xor[i] = prefix_xor[i-1] ^ arr[i-1]

    for a,b in barr:
        result = prefix_xor[b] ^ prefix_xor[a-1]
        print(result)

n, q = map(int, input().split())
arr = list(map(int, input().split()))

barr = []
for _ in range(q):
    a, b = map(int, input().split())
    barr.append([a,b])

xor_sum(n,arr,barr)

# Input:

# 8 4
# 3 2 4 5 1 1 5 3
# 2 4
# 5 6
# 1 8
# 3 3
# Output:

# 3
# 0
# 6
# 4

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