Submission #285875

# Submission time Handle Problem Language Result Execution time Memory
285875 2020-08-29T17:09:12 Z wildturtle XORanges (eJOI19_xoranges) C++14
100 / 100
936 ms 9720 KB
#include<bits/stdc++.h>
using namespace std;
long long a,b,c,d,i,e,f,g,n,m,k,l,A[500005],x,BITree[500005],BITree1[500005],t;
int getSum(int index) {
    int sum = 0;
    index = index + 1; 
    while (index>0) {
        sum ^= BITree[index]; 
        index -= index & (-index); 
    } 
    return sum; 
}
void updateBIT(int index, int val) {
    index = index + 1; 
    while (index <= 200005) { 
    BITree[index] ^= val; 
    index += index & (-index); 
    } 
} 
int getSum1(int index) {
    int sum = 0;
    index = index + 1; 
    while (index>0) {
        sum ^= BITree1[index]; 
        index -= index & (-index); 
    } 
    return sum; 
}
void updateBIT1(int index, int val) {
    index = index + 1; 
    while (index <= 200005) { 
    BITree1[index] ^= val; 
    index += index & (-index); 
    } 
} 
int main() {
    cin>>n>>t;
    for(long long i=1;i<=n;i++) {
        cin>>A[i];
        if(i%2==1) updateBIT(i/2+i%2,A[i]);
        else updateBIT1(i/2,A[i]);
    }
    while(t--) {
        cin>>a;
        if(a==1) {
            cin>>a>>b;
            if(a%2==1) {
                updateBIT(a/2+a%2,A[a]);
                updateBIT(a/2+a%2,b);
                A[a]=b;
            }
            else {
                updateBIT1(a/2,A[a]);
                updateBIT1(a/2,b);
                A[a]=b;                
            }
        }
        else {
            cin>>a>>b;
            if(a%2!=b%2) { cout<<0<<endl; continue; }
            if(a%2==1) {
                a=a/2+a%2;
                b=b/2+b%2;
                c=getSum(a-1)^getSum(b);
                cout<<c<<endl;
            }
            else {
                a/=2;
                b/=2;
                c=getSum1(a-1)^getSum1(b);
                cout<<c<<endl;
            }
        }
    }
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 384 KB Output is correct
2 Correct 3 ms 384 KB Output is correct
3 Correct 3 ms 384 KB Output is correct
4 Correct 3 ms 384 KB Output is correct
5 Correct 3 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 3 ms 384 KB Output is correct
7 Correct 3 ms 384 KB Output is correct
8 Correct 3 ms 384 KB Output is correct
9 Correct 3 ms 384 KB Output is correct
10 Correct 3 ms 384 KB Output is correct
11 Correct 18 ms 640 KB Output is correct
12 Correct 18 ms 640 KB Output is correct
13 Correct 21 ms 640 KB Output is correct
14 Correct 22 ms 680 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 927 ms 9720 KB Output is correct
2 Correct 932 ms 9684 KB Output is correct
3 Correct 936 ms 9592 KB Output is correct
4 Correct 906 ms 9500 KB Output is correct
5 Correct 918 ms 9312 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 3 ms 384 KB Output is correct
7 Correct 3 ms 384 KB Output is correct
8 Correct 3 ms 384 KB Output is correct
9 Correct 3 ms 384 KB Output is correct
10 Correct 3 ms 384 KB Output is correct
11 Correct 18 ms 640 KB Output is correct
12 Correct 18 ms 640 KB Output is correct
13 Correct 21 ms 640 KB Output is correct
14 Correct 22 ms 680 KB Output is correct
15 Correct 927 ms 9720 KB Output is correct
16 Correct 932 ms 9684 KB Output is correct
17 Correct 936 ms 9592 KB Output is correct
18 Correct 906 ms 9500 KB Output is correct
19 Correct 918 ms 9312 KB Output is correct
20 Correct 736 ms 9352 KB Output is correct
21 Correct 787 ms 9336 KB Output is correct
22 Correct 760 ms 9336 KB Output is correct
23 Correct 883 ms 9208 KB Output is correct
24 Correct 877 ms 9352 KB Output is correct