답안 #592248

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
592248 2022-07-08T19:32:36 Z Iwanttobreakfree XORanges (eJOI19_xoranges) C++
0 / 100
531 ms 11144 KB
#include <iostream>
#include <vector>
using namespace std;
void build(int n,int l,int r,vector<int>& t,vector<int>& li){
    if(l==r)t[n]=li[l];
    else{
        int mid=(r+l)/2;
        build(n<<1,l,mid,t,li);
        build((n<<1)+1,mid+1,r,t,li);
        t[n]=t[n<<1]^t[(n<<1)+1];
    }
}
void p_upd(int n,int l,int r,vector<int>& t,int x,int y){
    if(l>x||r<x)return;
    if(l==r&&l==x)t[n]=y;
    else{
        int mid=(r+l)/2;
        p_upd(n<<1,l,mid,t,x,y);
        p_upd((n<<1)+1,mid+1,r,t,x,y);
        t[n]=t[n<<1]^t[(n<<1)+1];
    }
}
int val(int n,int l,int r,vector<int>& t,int x,int y){
    if(l>y||r<x)return 0;
    if(l>=x&&r<=y)return t[n];
    else{
        int mid=(r+l)/2;
        int valls=val(n<<1,l,mid,t,x,y);
        int valrs=val((n<<1)+1,mid+1,r,t,x,y);
        return valls^valrs;
    }
}
int main(){
    int n,q,t,x,y;
    cin>>n>>q;
    vector<int> l1(n/2),l2(n-n/2);
    vector<int> t1(2*n),t2(2*(n-n/2));
    for(int i=0;i<n;i++){
        cin>>x;
        if(i&1)l1[i/2]=x;
        else l2[i/2]=x;
    }
    //for(int i=0;i<l2.size();i++)cout<<l2[i]<<' ';
    build(1,0,n/2-1,t1,l1);
    build(1,0,n-n/2-1,t2,l2);
    while(q--){
        cin>>t>>x>>y;
        if(t==1){
            if(x&1)p_upd(1,0,n-n/2-1,t2,(x-1)/2,y);
            else p_upd(1,0,n/2-1,t1,(x-1)/2,y);
        }else{
            if((y-x)&1)cout<<0<<'\n';
            else{
                if(x&1)cout<<val(1,0,n-n/2-1,t2,(x-1)/2,(y-1)/2);
                else cout<<val(1,0,n/2-1,t1,(x-1)/2,(y-1)/2);
                cout<<'\n';
            }
        }
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 1 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 468 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 1 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 531 ms 11144 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 1 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -