답안 #592255

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
592255 2022-07-08T19:55:51 Z Iwanttobreakfree XORanges (eJOI19_xoranges) C++
38 / 100
616 ms 65536 KB
#include <iostream>
#include <vector>
using namespace std;
void build(int n,int l,int r,vector<int>& t,vector<int>& li){
    //cout<<l<<' '<<r<<'\n';
    if(l>=r)return;
    if(l+1==r)t[n]=li[l];
    else{
        int mid=(r+l)/2;
        build(n<<1,l,mid,t,li);
        build((n<<1)+1,mid,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+1==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,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){
    //cout<<l<<' '<<r<<'\n';
    //return 0;
    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,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(4*(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]<<' ';
    if(n>1)build(1,0,n/2,t1,l1);
    build(1,0,n-n/2,t2,l2);
    //cout<<"ok ";
    while(q--){
        cin>>t>>x>>y;
        if(t==1){
            if(x&1)p_upd(1,0,n-n/2,t2,(x-1)/2,y);
            else p_upd(1,0,n/2,t1,(x-1)/2,y);
        }else{
            if((y-x)&1)cout<<0<<'\n';
            else{
                if(x&1)cout<<val(1,0,n-n/2,t2,(x-1)/2,(y-1)/2+1);
                else cout<<val(1,0,n/2,t1,(x-1)/2,(y-1)/2+1);
                cout<<'\n';
            }
        }
    }
}
# 결과 실행 시간 메모리 Grader output
1 Runtime error 42 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 212 KB Output is correct
2 Correct 3 ms 212 KB Output is correct
3 Correct 3 ms 212 KB Output is correct
4 Correct 2 ms 308 KB Output is correct
5 Correct 2 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 42 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 610 ms 5376 KB Output is correct
2 Correct 588 ms 10260 KB Output is correct
3 Correct 616 ms 10284 KB Output is correct
4 Correct 599 ms 9896 KB Output is correct
5 Correct 573 ms 9916 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 42 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -