답안 #978056

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
978056 2024-05-08T17:52:59 Z vjudge1 XORanges (eJOI19_xoranges) C++14
100 / 100
124 ms 7772 KB
#include<bits/stdc++.h>
#define ll long long

using namespace std;

const int mxN = 2e5 + 5;

void update(int l,int r, int idx , int val , int node , vector<int>& seg){
    if(l>idx || r<idx) return ;

    if(l == r){
        seg[node] = val;
        return ;
    }

    int mid = (l + r) / 2;

    update(l,mid , idx,val , node*2 ,seg);
    update(mid+1,r, idx,val , node*2 + 1,seg);

    seg[node] = seg[node*2] ^ seg[node*2 + 1];
}

int query(int l,int r, int curr_l , int curr_r , int node ,vector<int>& seg){
    if(curr_l>r || curr_r<l) return 0;
    if(l<=curr_l && curr_r<=r) return seg[node];

    int mid = (curr_l + curr_r) / 2;

    return query(l,r,curr_l,mid , node*2 ,seg) ^ query(l,r,mid+1,curr_r,node*2 + 1  , seg);
}

int main(){
    ios::sync_with_stdio(0),cin.tie(0);

    int n,q;
    
    cin>> n >> q;

    vector<int> segA(4*n , 0);
    vector<int> segB(4*n , 0);

    for(int i=1;i<=n;i++){
        int val;
        cin>> val;

        if(i%2 == 1) update(1,n,i,val,1,segA);
        else update(1,n,i,val,1,segB);
    }

    while(q--){
        int cmd;
        cin>> cmd;

        if(cmd == 1){
            int idx,val;
            cin>> idx >> val;

            if(idx%2 == 1) update(1,n,idx,val,1,segA);
            else update(1,n,idx,val,1,segB);

        }else{
            int l,r;
            cin>> l >> r;

            int len = r-l+1;

            if(len % 2 == 0) cout<< 0 << "\n";
            else{
                if(l%2 == 1) cout<< query(l,r,1,n,1,segA) << "\n";
                else cout<< query(l,r,1,n,1,segB) << "\n";
            }
        }
    }

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 5 ms 604 KB Output is correct
12 Correct 3 ms 604 KB Output is correct
13 Correct 3 ms 604 KB Output is correct
14 Correct 3 ms 604 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 119 ms 7764 KB Output is correct
2 Correct 117 ms 7760 KB Output is correct
3 Correct 117 ms 7764 KB Output is correct
4 Correct 117 ms 7760 KB Output is correct
5 Correct 109 ms 7764 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 5 ms 604 KB Output is correct
12 Correct 3 ms 604 KB Output is correct
13 Correct 3 ms 604 KB Output is correct
14 Correct 3 ms 604 KB Output is correct
15 Correct 119 ms 7764 KB Output is correct
16 Correct 117 ms 7760 KB Output is correct
17 Correct 117 ms 7764 KB Output is correct
18 Correct 117 ms 7760 KB Output is correct
19 Correct 109 ms 7764 KB Output is correct
20 Correct 115 ms 7248 KB Output is correct
21 Correct 114 ms 7248 KB Output is correct
22 Correct 124 ms 7252 KB Output is correct
23 Correct 112 ms 7772 KB Output is correct
24 Correct 111 ms 7744 KB Output is correct