Submission #406234

# Submission time Handle Problem Language Result Execution time Memory
406234 2021-05-17T09:46:28 Z Ronin13 XORanges (eJOI19_xoranges) C++14
100 / 100
671 ms 14152 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(800001);
vector<int>te(800001);
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 4 ms 8140 KB Output is correct
2 Correct 4 ms 8012 KB Output is correct
3 Correct 4 ms 8012 KB Output is correct
4 Correct 4 ms 8140 KB Output is correct
5 Correct 5 ms 8012 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 8140 KB Output is correct
2 Correct 6 ms 8136 KB Output is correct
3 Correct 6 ms 8040 KB Output is correct
4 Correct 6 ms 8140 KB Output is correct
5 Correct 6 ms 8140 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 8140 KB Output is correct
2 Correct 4 ms 8012 KB Output is correct
3 Correct 4 ms 8012 KB Output is correct
4 Correct 4 ms 8140 KB Output is correct
5 Correct 5 ms 8012 KB Output is correct
6 Correct 6 ms 8140 KB Output is correct
7 Correct 6 ms 8136 KB Output is correct
8 Correct 6 ms 8040 KB Output is correct
9 Correct 6 ms 8140 KB Output is correct
10 Correct 6 ms 8140 KB Output is correct
11 Correct 15 ms 8140 KB Output is correct
12 Correct 16 ms 8112 KB Output is correct
13 Correct 19 ms 8148 KB Output is correct
14 Correct 20 ms 8140 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 658 ms 11980 KB Output is correct
2 Correct 662 ms 14108 KB Output is correct
3 Correct 671 ms 14152 KB Output is correct
4 Correct 645 ms 13716 KB Output is correct
5 Correct 651 ms 13736 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 8140 KB Output is correct
2 Correct 4 ms 8012 KB Output is correct
3 Correct 4 ms 8012 KB Output is correct
4 Correct 4 ms 8140 KB Output is correct
5 Correct 5 ms 8012 KB Output is correct
6 Correct 6 ms 8140 KB Output is correct
7 Correct 6 ms 8136 KB Output is correct
8 Correct 6 ms 8040 KB Output is correct
9 Correct 6 ms 8140 KB Output is correct
10 Correct 6 ms 8140 KB Output is correct
11 Correct 15 ms 8140 KB Output is correct
12 Correct 16 ms 8112 KB Output is correct
13 Correct 19 ms 8148 KB Output is correct
14 Correct 20 ms 8140 KB Output is correct
15 Correct 658 ms 11980 KB Output is correct
16 Correct 662 ms 14108 KB Output is correct
17 Correct 671 ms 14152 KB Output is correct
18 Correct 645 ms 13716 KB Output is correct
19 Correct 651 ms 13736 KB Output is correct
20 Correct 540 ms 13780 KB Output is correct
21 Correct 531 ms 13788 KB Output is correct
22 Correct 535 ms 13896 KB Output is correct
23 Correct 640 ms 13800 KB Output is correct
24 Correct 626 ms 13732 KB Output is correct