Submission #447577

# Submission time Handle Problem Language Result Execution time Memory
447577 2021-07-26T20:44:28 Z MrDeboo XORanges (eJOI19_xoranges) C++17
100 / 100
180 ms 13568 KB
#include <bits/stdc++.h>
#define endl '\n'
#define int long long
#define mod 1000000007
#define INF 1000000000000000000
using namespace std;
int seg1[600000];
int seg2[600000];
int N,a,b,c;
int solve1(int l=1,int r=N,int in=1){
    if(r<b||c<l)return 0;
    if(l>=b&&r<=c)return seg1[in];
    int mid=(l+r)/2;
    return solve1(l,mid,in*2)^solve1(mid+1,r,in*2+1);
}
int solve2(int l=1,int r=N,int in=1){
    if(r<b||c<l)return 0;
    if(l>=b&&r<=c)return seg2[in];
    int mid=(l+r)/2;
    return solve2(l,mid,in*2)^solve2(mid+1,r,in*2+1);
}
signed main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    //freopen("tttt.in", "r", stdin);
    //freopen("tttt.out", "w", stdout);
    int n,q;
    cin>>n>>q;
    N=exp2(ceil(log2(n)));
    for(int i=0;i<n;i++){
        if(i&1)cin>>seg1[i+N];
        else cin>>seg2[i+N];
    }
    for(int i=N-1;i;i--)seg1[i]=seg1[i*2]^seg1[i*2+1];
    for(int i=N-1;i;i--)seg2[i]=seg2[i*2]^seg2[i*2+1];
    // cout<<seg2[1]<<endl;
    while(q--){
        cin>>a>>b>>c;
        if(a&1){
            int in=N+b-1;
            if(b&1){
                seg2[in]=c;
                in/=2;
                while(in){
                    seg2[in]=seg2[in*2]^seg2[in*2+1];
                    in/=2;
                }
            }
            else{
                seg1[in]=c;
                in/=2;
                while(in){
                    seg1[in]=seg1[in*2]^seg1[in*2+1];
                    in/=2;
                }
            }
        }
        else{
            if((c-b+1)%2==1){
                if(b&1)cout<<solve2()<<endl;
                else cout<<solve1()<<endl;
            }
            else{
                cout<<0<<endl;
            }
        }
    }
}
/*
a b c
ab bc
abc
a- 3
b- 4
c- 3
-------------
a b c d
ab bc cd
abc bcd
abcd
a- 4
b- 6
c- 6
d- 4
--------------
a b c d e
ab bc cd de
abc bcd cde
abcd bcde
abcde
a- 5
b- 8
c- 9
d- 8
e- 5
*/
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 328 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 328 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 3 ms 588 KB Output is correct
12 Correct 4 ms 588 KB Output is correct
13 Correct 4 ms 588 KB Output is correct
14 Correct 4 ms 572 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 180 ms 8724 KB Output is correct
2 Correct 164 ms 13512 KB Output is correct
3 Correct 176 ms 13568 KB Output is correct
4 Correct 143 ms 13116 KB Output is correct
5 Correct 153 ms 13196 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 328 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 3 ms 588 KB Output is correct
12 Correct 4 ms 588 KB Output is correct
13 Correct 4 ms 588 KB Output is correct
14 Correct 4 ms 572 KB Output is correct
15 Correct 180 ms 8724 KB Output is correct
16 Correct 164 ms 13512 KB Output is correct
17 Correct 176 ms 13568 KB Output is correct
18 Correct 143 ms 13116 KB Output is correct
19 Correct 153 ms 13196 KB Output is correct
20 Correct 147 ms 13252 KB Output is correct
21 Correct 143 ms 13196 KB Output is correct
22 Correct 141 ms 13316 KB Output is correct
23 Correct 142 ms 13108 KB Output is correct
24 Correct 146 ms 13124 KB Output is correct