Submission #774978

# Submission time Handle Problem Language Result Execution time Memory
774978 2023-07-06T06:25:29 Z vjudge1 XORanges (eJOI19_xoranges) C++17
0 / 100
20 ms 7976 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define mid (start+end)/2
#define faster ios_base::sync_with_stdio(false);cin.tie(NULL);
int dizi[200005],tree[200005],sum=0;

void build(int node,int start,int end){
    if(start==end){
        tree[node]=dizi[start];
        return ;
    }
    build(node*2,start,mid),build(node*2+1,mid+1,end);
    tree[node]=tree[node*2]^tree[node*2+1];
}

void query(int node,int start,int end,int l,int r){
    if(start>end || start>r || end<l)return;
    if(start>=l && end<=r){
        sum^=tree[node];
        return ;
    }
    query(node*2,start,mid,l,r),query(node*2+1,mid+1,end,l,r);
}

void update(int node,int start,int end,int pos,int val){
    if(start==end && start==pos){
        tree[node]=val;
        return ;
    }
    if(!(start<=pos && end>=pos))return ;
    update(node*2,start,mid,pos,val),update(node*2+1,mid+1,end,pos,val);
    tree[node]=tree[node*2]^tree[node*2+1];
}

int32_t main(){
    faster
    int n,q;cin>>n>>q;
    for(int i=1;i<=n;i++)cin>>dizi[i];
    build(1,1,n);
    while(q--){
        int t,l,r;cin>>t>>l>>r;
        if(t==1){
            update(1,1,n,l,r);
        }
        else{
            sum=0;
            query(1,1,n,l,r);
            cout<<sum<<'\n';
        }
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 20 ms 7976 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -