Submission #430837

# Submission time Handle Problem Language Result Execution time Memory
430837 2021-06-17T06:57:05 Z NintsiChkhaidze XORanges (eJOI19_xoranges) C++14
100 / 100
207 ms 15880 KB
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define left (node<<1),l,((l+r)>>1)
#define right ((node<<1)|1),((l+r)>>1) + 1,r
using namespace std;
const int N = 200005;
ll odd[4*N],even[4*N],a[N];
bool D = 1;
void build(int node,int l,int r){
    if (l == r){
        if (l%2) odd[node] = a[l];
        else even[node] = a[l];
        return;
    }
    build(left),build(right);
    
    odd[node] = odd[(node<<1)]^odd[((node<<1)|1)];
    even[node] = even[(node<<1)]^even[((node<<1)|1)];
}
void upd(int node,int l,int r,int idx,ll val){
    if (l == r){
        if (l%2) odd[node] = val,even[node] = 0;
        else even[node] = val,odd[node] = 0;
        return;
    }
    if (idx > (l+r)>>1) upd(right,idx,val);
    else upd(left,idx,val);
    
    odd[node] = odd[(node<<1)]^odd[((node<<1)|1)];
    even[node] = even[(node<<1)]^even[((node<<1)|1)];
}
ll get(int node,int l,int r,int L,int R){
    if (r < L || R < l) return 0;
    if (L <= l && r <= R) {
        if (D) return odd[node];
        return even[node];
    }
    ll x = get(left,L,R),y = get(right,L,R);
    return x^y;
}
int main (){
    ios_base::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL);
    int n,q;
    cin>>n>>q;
    
    for (int i=1;i<=n;i++)
        cin>>a[i];
        
    build(1,1,n);
    
    while(q--){
        int tp,x,y;
        cin>>tp>>x>>y;
        if (tp == 1) upd(1,1,n,x,y);
        else {
            D = 1;
            if (!(x%2)) D = 0;
            if ((y-x+1)%2) cout<<get(1,1,n,x,y)<<"\n";
            else cout<<0<<"\n";
        }
    }
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 4 ms 716 KB Output is correct
12 Correct 4 ms 716 KB Output is correct
13 Correct 4 ms 724 KB Output is correct
14 Correct 5 ms 716 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 187 ms 11212 KB Output is correct
2 Correct 207 ms 11212 KB Output is correct
3 Correct 201 ms 11204 KB Output is correct
4 Correct 149 ms 11220 KB Output is correct
5 Correct 143 ms 11180 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 4 ms 716 KB Output is correct
12 Correct 4 ms 716 KB Output is correct
13 Correct 4 ms 724 KB Output is correct
14 Correct 5 ms 716 KB Output is correct
15 Correct 187 ms 11212 KB Output is correct
16 Correct 207 ms 11212 KB Output is correct
17 Correct 201 ms 11204 KB Output is correct
18 Correct 149 ms 11220 KB Output is correct
19 Correct 143 ms 11180 KB Output is correct
20 Correct 182 ms 15816 KB Output is correct
21 Correct 180 ms 15800 KB Output is correct
22 Correct 182 ms 15880 KB Output is correct
23 Correct 148 ms 15672 KB Output is correct
24 Correct 147 ms 15744 KB Output is correct