답안 #803188

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
803188 2023-08-03T00:13:13 Z Essa2006 XORanges (eJOI19_xoranges) C++14
100 / 100
461 ms 4724 KB
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define endl '\n'
#define FF first
#define SS second
#define all(a) a.begin(), a.end()
#define mod (ll)(1000000007)
const int pr=18, s_p=1<<pr, e_p=(1<<(pr+1))-1;
int n, q;
int S[2][1<<(pr+1)];
void update(int par, int ind, int new_){
    S[par][ind]=new_;
    S[!par][ind]=0;
    while(ind/=2){
        S[par][ind]=S[par][ind*2]^S[par][ind*2+1];
        S[!par][ind]=S[!par][ind*2]^S[!par][ind*2+1];
    }
}
 
int get(int id, int u, int v, int l, int r, int par){
    if(l>v || r<u)
        return 0;
    if(l>=u && r<=v)
        return S[par][id];
    int md=(l+r)/2;
    return get(id*2, u, v, l, md, par)^get(id*2+1, u, v, md+1, r, par);
}
int main(){
    cin>>n>>q;
    for(int i=1, a;i<=n;i++){
        cin>>a;
        update(i&1, i+s_p, a);
    }
    while(q--){
        int type, i, x;
        cin>>type>>i>>x;
        if(type==1){
            update(i&1, i+s_p, x);
        }
        else if(type==2){
            int ans=0; 
            if((x-i+1)&1)
                ans=get(1, i+s_p, x+s_p, s_p, e_p, i&1);
            cout<<ans<<endl;
        }
    }
}
# 결과 실행 시간 메모리 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 1 ms 340 KB Output is correct
2 Correct 2 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 2 ms 340 KB Output is correct
5 Correct 1 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
6 Correct 1 ms 340 KB Output is correct
7 Correct 2 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 2 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 8 ms 468 KB Output is correct
12 Correct 8 ms 340 KB Output is correct
13 Correct 10 ms 468 KB Output is correct
14 Correct 10 ms 476 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 461 ms 4652 KB Output is correct
2 Correct 430 ms 4572 KB Output is correct
3 Correct 431 ms 4724 KB Output is correct
4 Correct 399 ms 4588 KB Output is correct
5 Correct 409 ms 4592 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
6 Correct 1 ms 340 KB Output is correct
7 Correct 2 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 2 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 8 ms 468 KB Output is correct
12 Correct 8 ms 340 KB Output is correct
13 Correct 10 ms 468 KB Output is correct
14 Correct 10 ms 476 KB Output is correct
15 Correct 461 ms 4652 KB Output is correct
16 Correct 430 ms 4572 KB Output is correct
17 Correct 431 ms 4724 KB Output is correct
18 Correct 399 ms 4588 KB Output is correct
19 Correct 409 ms 4592 KB Output is correct
20 Correct 313 ms 4032 KB Output is correct
21 Correct 310 ms 4136 KB Output is correct
22 Correct 306 ms 4040 KB Output is correct
23 Correct 441 ms 4668 KB Output is correct
24 Correct 388 ms 4516 KB Output is correct