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

Code

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

# Create the prefix XOR array
prefix = [0] * (n + 1)
for i in range(1, n + 1):
    prefix[i] = prefix[i - 1] ^ array[i - 1]

# Process queries
results = []
for i in range(2, 2 + q):
    a, b = map(int, input().split())
    result = prefix[b] ^ prefix[a - 1]
    results.append(result)

print("\n".join(map(str, results)))

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