Submission #579244

# Submission time Handle Problem Language Result Execution time Memory
579244 2022-06-18T15:48:44 Z Kipras XORanges (eJOI19_xoranges) C++17
100 / 100
211 ms 12572 KB
#include <bits/stdc++.h>

typedef long long ll;

using namespace std;

const ll maxN = 2e5+10;

int l[maxN*2], r[maxN*2], val1[maxN*2], val0[maxN*2];

int ind = 1;
ll n, m;

void build(int v){
    if(v >= n){
        l[v] = ind;
        r[v] = ind;
        ind++;
        val0[v]=0;
        val1[v]=0;
    }else{
        build(v*2);
        build(v*2+1);
        l[v] = l[v*2];
        r[v] = r[v*2+1];
        //cout<<v<<" "<<l[v]<<" "<<r[v]<<endl;
    }
}

int query(int v, int L, int R){
    ll ret=0;
    if(L <= l[v] && r[v] <= R){
        if(L%2==0)ret = val0[v];
        else ret = val1[v];
        //cout<<"b";
    }else if(r[v] < L || R < l[v]){
        //cout<<"c";
        ret = 0;
    }else{
        //cout<<"d";
        ret = query(v*2, L, R)^query(v*2+1, L, R);
    }
    //cout<<ret<<" "<<v<<" "<<L<<" "<<R<<" "<<l[v]<<" "<<r[v]<<" "<<endl;
    return ret;
}

void change(int v, int L, int R, int x){

    if(L <= l[v] && r[v] <= R){
        val0[v]=0;
        val1[v]=0;
        if(l[v]%2==0)val0[v]=x;
        else val1[v]=x;
    }else if(r[v] < L || R < l[v]){

    }else{
        change(v*2, L, R, x);
        change(v*2+1, L, R, x);
        val0[v] = val0[v*2]^val0[v*2+1];
        val1[v] = val1[v*2]^val1[v*2+1];
    }
}



int main()
{

    ios_base::sync_with_stdio(0);cin.tie(nullptr);

    cin>>n>>m;

    build(1);

    for(int i = 1; i <= n; i++){
        ll aa;
        cin>>aa;
        change(1, i, i, aa);
    }

    for(int i = 1; i <= m; i++){
        ll op;
        cin>>op;
        if(op==2){
            ll aa, bb;
            cin>>aa>>bb;
            if(abs(aa-bb)%2==1){
                cout<<"0\n";
            }else{
                cout<<query(1, aa, bb)<<"\n";
            }
        }else{
            ll aa, bb;
            cin>>aa>>bb;
            change(1, aa, aa, bb);
        }
    }

    return 0;
}
# 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 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 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
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 6 ms 600 KB Output is correct
12 Correct 5 ms 604 KB Output is correct
13 Correct 4 ms 596 KB Output is correct
14 Correct 4 ms 596 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 191 ms 7732 KB Output is correct
2 Correct 204 ms 12516 KB Output is correct
3 Correct 187 ms 12572 KB Output is correct
4 Correct 169 ms 12220 KB Output is correct
5 Correct 150 ms 12268 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
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 6 ms 600 KB Output is correct
12 Correct 5 ms 604 KB Output is correct
13 Correct 4 ms 596 KB Output is correct
14 Correct 4 ms 596 KB Output is correct
15 Correct 191 ms 7732 KB Output is correct
16 Correct 204 ms 12516 KB Output is correct
17 Correct 187 ms 12572 KB Output is correct
18 Correct 169 ms 12220 KB Output is correct
19 Correct 150 ms 12268 KB Output is correct
20 Correct 206 ms 12240 KB Output is correct
21 Correct 196 ms 12272 KB Output is correct
22 Correct 211 ms 12276 KB Output is correct
23 Correct 152 ms 12244 KB Output is correct
24 Correct 169 ms 12196 KB Output is correct