Submission #778352

# Submission time Handle Problem Language Result Execution time Memory
778352 2023-07-10T08:48:40 Z andrei_iorgulescu XORanges (eJOI19_xoranges) C++14
100 / 100
129 ms 10432 KB
#include <bits/stdc++.h>

using namespace std;

int n,q;
int aintpar[800005];
int aintimpar[800005];

void update(int nod,int l,int r,int pos,int val)
{
    if (l == r)
    {
        if (l % 2 == 1)
            aintimpar[nod] = val;
        else
            aintpar[nod] = val;
        return;
    }
    int mij = (l + r) / 2;
    if (pos <= mij)
        update(2 * nod,l,mij,pos,val);
    else
        update(2 * nod + 1,mij + 1,r,pos,val);
    aintpar[nod] = aintpar[2 * nod] ^ aintpar[2 * nod + 1];
    aintimpar[nod] = aintimpar[2 * nod] ^ aintimpar[2 * nod + 1];
}

int querypar(int nod,int l,int r,int st,int dr)
{
    if (r < st or dr < l)
        return 0;
    if (st <= l and r <= dr)
        return aintpar[nod];
    int mij = (l + r) / 2;
    return querypar(2 * nod,l,mij,st,dr) ^ querypar(2 * nod + 1,mij + 1,r,st,dr);
}

int queryimpar(int nod,int l,int r,int st,int dr)
{
    if (r < st or dr < l)
        return 0;
    if (st <= l and r <= dr)
        return aintimpar[nod];
    int mij = (l + r) / 2;
    return queryimpar(2 * nod,l,mij,st,dr) ^ queryimpar(2 * nod + 1,mij + 1,r,st,dr);
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin >> n >> q;
    for (int i = 1; i <= n; i++)
    {
        int x;
        cin >> x;
        update(1,1,n,i,x);
    }
    for (int i = 1; i <= q; i++)
    {
        int tip,x,y;
        cin >> tip >> x >> y;
        if (tip == 1)
            update(1,1,n,x,y);
        else
        {
            if (y % 2 != x % 2)
                cout << 0 << '\n';
            else if (x % 2 == 0)
                cout << querypar(1,1,n,x,y) << '\n';
            else
                cout << queryimpar(1,1,n,x,y) << '\n';
        }
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 3 ms 468 KB Output is correct
12 Correct 3 ms 468 KB Output is correct
13 Correct 3 ms 468 KB Output is correct
14 Correct 3 ms 468 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 115 ms 10292 KB Output is correct
2 Correct 129 ms 10432 KB Output is correct
3 Correct 126 ms 10368 KB Output is correct
4 Correct 104 ms 10004 KB Output is correct
5 Correct 104 ms 10120 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 3 ms 468 KB Output is correct
12 Correct 3 ms 468 KB Output is correct
13 Correct 3 ms 468 KB Output is correct
14 Correct 3 ms 468 KB Output is correct
15 Correct 115 ms 10292 KB Output is correct
16 Correct 129 ms 10432 KB Output is correct
17 Correct 126 ms 10368 KB Output is correct
18 Correct 104 ms 10004 KB Output is correct
19 Correct 104 ms 10120 KB Output is correct
20 Correct 107 ms 10172 KB Output is correct
21 Correct 111 ms 10304 KB Output is correct
22 Correct 109 ms 10088 KB Output is correct
23 Correct 105 ms 10076 KB Output is correct
24 Correct 117 ms 10088 KB Output is correct