Submission #406231

# Submission time Handle Problem Language Result Execution time Memory
406231 2021-05-17T09:45:26 Z Ronin13 XORanges (eJOI19_xoranges) C++14
55 / 100
99 ms 12016 KB
#include<bits/stdc++.h>
#define ll long long
#define f first
#define s second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define ull unsigned ll
#define pb push_back
#define epb emplace_back
#define INF 1e9+1;
using namespace std;

vector<int>to(400001);
vector<int>te(400001);
vector<int>a(400001);
void build(int v,int l,int r){
    if(l==r){
        if(l%2)
        to[v]=a[l],te[v]=0;
        else te[v]=a[l],to[v]=0;
    }
    else{
        int m=(l+r)/2;
        build(2*v,l,m);
        build(2*v+1,m+1,r);
        te[v]=te[2*v]^te[2*v+1];
        to[v]=to[2*v]^to[2*v+1];
    }
}

void update(int v,int l,int r,int nw,int pos){
    if(l==r){
        if(l%2==0)te[v]=nw;
        else to[v]=nw;
        return;
    }

    int m=(l+r)/2;
    if(m>=pos)update(2*v,l,m,nw,pos);
    else update(2*v+1,m+1,r,nw,pos);
    te[v]=te[2*v]^te[2*v+1];
    to[v]=to[2*v]^to[2*v+1];
}

int getodd(int v,int l,int r,int tl,int tr){
    if(l==tl&&r==tr){
        return to[v];
    }
    int tm=(tl+tr)/2;
    if(r<=tm)return getodd(2*v,l,r,tl,tm);
    if(l>tm)return getodd(2*v+1,l,r,tm+1,tr);
    return getodd(2*v,l,tm,tl,tm)^getodd(2*v+1,tm+1,r,tm+1,tr);
}

int geteven(int v,int l,int r,int tl,int tr){
      if(l==tl&&r==tr){
        return te[v];
    }
    int tm=(tl+tr)/2;
    if(r<=tm)return geteven(2*v,l,r,tl,tm);
    if(l>tm)return geteven(2*v+1,l,r,tm+1,tr);
    return geteven(2*v,l,tm,tl,tm)^geteven(2*v+1,tm+1,r,tm+1,tr);
}

void solve(){
    int n,q;cin>>n>>q;
    for(int i=1;i<=n;i++)cin>>a[i];
    build(1,1,n);
    while(q--){
        int ind;cin>>ind;
        switch(ind){
        case 1:
            int pos,nw;cin>>pos>>nw;
            update(1,1,n,nw,pos);
            break;
        case 2:int l,r;cin>>l>>r;
            if((r-l)&1)cout<<0<<"\n";
            else {
                if(l%2)cout<<getodd(1,l,r,1,n)<<"\n";
                else cout<<geteven(1,l,r,1,n)<<"\n";

                }
        }
    }
}

int main(){
    int t;t=1;
    while(t--){
        solve();
    }
}
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4940 KB Output is correct
2 Correct 3 ms 4940 KB Output is correct
3 Correct 4 ms 4940 KB Output is correct
4 Correct 4 ms 5004 KB Output is correct
5 Correct 3 ms 5008 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 5008 KB Output is correct
2 Correct 6 ms 4940 KB Output is correct
3 Correct 5 ms 5024 KB Output is correct
4 Correct 5 ms 4940 KB Output is correct
5 Correct 5 ms 5020 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4940 KB Output is correct
2 Correct 3 ms 4940 KB Output is correct
3 Correct 4 ms 4940 KB Output is correct
4 Correct 4 ms 5004 KB Output is correct
5 Correct 3 ms 5008 KB Output is correct
6 Correct 4 ms 5008 KB Output is correct
7 Correct 6 ms 4940 KB Output is correct
8 Correct 5 ms 5024 KB Output is correct
9 Correct 5 ms 4940 KB Output is correct
10 Correct 5 ms 5020 KB Output is correct
11 Correct 15 ms 5016 KB Output is correct
12 Correct 15 ms 5068 KB Output is correct
13 Correct 18 ms 5068 KB Output is correct
14 Correct 20 ms 5140 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 99 ms 12016 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4940 KB Output is correct
2 Correct 3 ms 4940 KB Output is correct
3 Correct 4 ms 4940 KB Output is correct
4 Correct 4 ms 5004 KB Output is correct
5 Correct 3 ms 5008 KB Output is correct
6 Correct 4 ms 5008 KB Output is correct
7 Correct 6 ms 4940 KB Output is correct
8 Correct 5 ms 5024 KB Output is correct
9 Correct 5 ms 4940 KB Output is correct
10 Correct 5 ms 5020 KB Output is correct
11 Correct 15 ms 5016 KB Output is correct
12 Correct 15 ms 5068 KB Output is correct
13 Correct 18 ms 5068 KB Output is correct
14 Correct 20 ms 5140 KB Output is correct
15 Runtime error 99 ms 12016 KB Execution killed with signal 11
16 Halted 0 ms 0 KB -