답안 #775012

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
775012 2023-07-06T06:47:35 Z vjudge1 XORanges (eJOI19_xoranges) C++17
100 / 100
129 ms 16076 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],tese[800005],cise[800005],sum=0;

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

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

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

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


void updatecift(int node,int start,int end,int pos,int val){
    if(!(start<=pos && end>=pos))return ;
    if(start==end && start==pos){
        cise[node]=val;
        return ;
    }
    updatecift(node*2,start,mid,pos,val),updatecift(node*2+1,mid+1,end,pos,val);
    cise[node]=cise[node*2]^cise[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){
            if(l%2==1)updatetek(1,1,n,l,r);
            else updatecift(1,1,n,l,r);
        }
        else{
            sum=0;
            if(l%2==1 && r%2==1)querytek(1,1,n,l,r);
            else if(l%2==0 && r%2==0)querycift(1,1,n,l,r);
            cout<<sum<<'\n';
        }
    }
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 328 KB Output is correct
3 Correct 1 ms 324 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 328 KB Output is correct
3 Correct 1 ms 324 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 3 ms 724 KB Output is correct
12 Correct 3 ms 776 KB Output is correct
13 Correct 3 ms 724 KB Output is correct
14 Correct 3 ms 700 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 111 ms 11168 KB Output is correct
2 Correct 123 ms 16056 KB Output is correct
3 Correct 101 ms 16076 KB Output is correct
4 Correct 88 ms 15684 KB Output is correct
5 Correct 93 ms 15692 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 328 KB Output is correct
3 Correct 1 ms 324 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 3 ms 724 KB Output is correct
12 Correct 3 ms 776 KB Output is correct
13 Correct 3 ms 724 KB Output is correct
14 Correct 3 ms 700 KB Output is correct
15 Correct 111 ms 11168 KB Output is correct
16 Correct 123 ms 16056 KB Output is correct
17 Correct 101 ms 16076 KB Output is correct
18 Correct 88 ms 15684 KB Output is correct
19 Correct 93 ms 15692 KB Output is correct
20 Correct 129 ms 15748 KB Output is correct
21 Correct 111 ms 15760 KB Output is correct
22 Correct 101 ms 15756 KB Output is correct
23 Correct 92 ms 15724 KB Output is correct
24 Correct 96 ms 15816 KB Output is correct