Submission #803161

# Submission time Handle Problem Language Result Execution time Memory
803161 2023-08-02T23:55:08 Z Essa2006 XORanges (eJOI19_xoranges) C++14
0 / 100
32 ms 65536 KB
#include<bits/stdc++.h>
using namespace std;
#define int long long 
#define endl '\n'
#define FF first
#define SS second
#define all(a) a.begin(), a.end()
#define mod (ll)(1000000007)
const int pr=20, s_p=1<<pr, e_p=(1<<(pr+1))-1;
int n, q;
vector<vector<vector<int>>>S;
void pre(){
    S.clear();
    S.resize(2, vector<vector<int>>(34, vector<int>(1<<(pr+2))));
}
void update(int par, int j, int ind, int new_){
    S[par][j][ind]=new_;
    S[!par][j][ind]=0;
    while(ind/=2){
        S[par][j][ind]=S[par][j][ind*2]^S[par][j][ind*2+1];
        S[!par][j][ind]=S[!par][j][ind*2]^S[!par][j][ind*2+1];
    }
}

bool get(int id, int u, int v, int l, int r, int par, int j){
    if(l>v || r<u)
        return 0;
    if(l>=u && r<=v)
        return S[par][j][id];
    int md=(l+r)/2;
    return get(id*2, u, v, l, md, par, j)^get(id*2+1, u, v, md+1, r, par, j);
}
signed main(){
    ios_base::sync_with_stdio(0);cin.tie(0);
    cin>>n>>q;
    pre();
    for(int i=1, a;i<=n;i++){
        cin>>a;
        for(int j=0;j<=31;j++){
            update(i&1, j, i+s_p, ((a&(1<<j))!=0));
        }
    }
    while(q--){
        int type, i, x;
        cin>>type>>i>>x;
        if(type==1){
            for(int j=0;j<=31;j++){
                update(i&1, j, i+s_p, ((x&(1<<j))!=0));
            }
        }
        else if(type==2){
            int ans=0; 
            for(int j=0;j<=31 && (x-i+1)&1;j++){
                bool odd=1;
                if(odd)
                    ans+=1<<j;
            }
            cout<<ans<<endl;
        }
    }
}
# Verdict Execution time Memory Grader output
1 Runtime error 31 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 32 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 31 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 32 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 31 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -