Submission details
Task:Xor sum
Sender:aalto26dm_007
Submission time:2026-09-21 16:29:26 +0300
Language:Python3 (PyPy3)
Status:READY
Result:ACCEPTED
Test results
testverdicttime
#1ACCEPTED0.04 sdetails
#2ACCEPTED0.21 sdetails

Code

import sys

input = sys.stdin.readline

class PrefixSum1D:
    def __init__(self, arr):
        self.p = [0] * (len(arr) + 1)
        for i, x in enumerate(arr):
            self.p[i + 1] = self.p[i] ^ x

    def xor_range(self, a, b):
        return self.p[b + 1] ^ self.p[a]


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

    prefix = PrefixSum1D(arr)

    out = []

    for _ in range(q):
        a, b = map(int, input().split())
        out.append(str(prefix.xor_range(a - 1, b - 1)))

    sys.stdout.write("\n".join(out) + ("\n" if out else ""))


if __name__ == "__main__":
    main()

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
...