Submission details
Task:Xor sum
Sender:klaava
Submission time:2025-09-22 17:10:06 +0300
Language:C++ (C++17)
Status:READY
Result:ACCEPTED
Test results
testverdicttime
#1ACCEPTED0.00 sdetails
#2ACCEPTED0.25 sdetails

Code

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

template <class T>
void print_v(vector<T> &v) { cout << "{"; for (auto x : v) cout << x << ","; cout << "\b}"; }

typedef long long ll;
int main()
{
    int n, q;
    cin >> n >> q;

    int  arr[n];
    int xorsum[n];


    for (int i = 0; i < n; i++) {
        cin >> arr[i]; 
     
    }
    xorsum[0] = arr[0]; 
    
    for (int i = 1; i < n; i++)
    {
        xorsum[i] = xorsum[i - 1] ^ arr[i];
    }

    int xorsums[q]; 
    for (int i = 0; i < q; i++) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        if (a == 0)
            xorsums[i] = xorsum[b];
        else {
                xorsums[i] = xorsum[b] ^ xorsum[a - 1];
        }
    } 

    for (int i = 0; i < q; i++)
        cout << xorsums[i] << "\n";

    return 0;
}

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