Submission #753087

# Submission time Handle Problem Language Result Execution time Memory
753087 2023-06-04T14:37:58 Z MateiKing80 XORanges (eJOI19_xoranges) C++14
100 / 100
513 ms 7292 KB
#include <iostream>
 
using namespace std;
 
long long v[200005];
long long aint1[1<<19];
long long aint2[1<<19];
 
 
void build1(long long poz, long long st, long long dr)
{
    if(st==dr)
    {
        aint1[poz]=v[2*st-1];
        return;
    }
    long long mid=(st+dr)/2;
    build1(2*poz,st,mid);
    build1(2*poz+1,mid+1,dr);
    aint1[poz]=(aint1[2*poz]^aint1[2*poz+1]);
}
 
void build2(long long poz, long long st, long long dr)
{
    if(st==dr)
    {
        aint2[poz]=v[2*st];
        return;
    }
    long long mid=(st+dr)/2;
    build2(2*poz,st,mid);
    build2(2*poz+1,mid+1,dr);
    aint2[poz]=(aint2[2*poz]^aint2[2*poz+1]);
}
 
 
void update1(long long poz, long long st, long long dr, long long a, long long b)
{
    if(st==dr)
    {
        aint1[poz]=b;
        return;
    }
    long long mid=(st+dr)/2;
    if(a<=mid)
        update1(2*poz,st,mid,a,b);
    else
        update1(2*poz+1,mid+1,dr,a,b);
    aint1[poz]=(aint1[2*poz]^aint1[2*poz+1]);
}
 
void update2(long long poz, long long st, long long dr, long long a, long long b)
{
    if(st==dr)
    {
        aint2[poz]=b;
        return;
    }
    long long mid=(st+dr)/2;
    if(a<=mid)
        update2(2*poz,st,mid,a,b);
    else
        update2(2*poz+1,mid+1,dr,a,b);
    aint2[poz]=(aint2[2*poz]^aint2[2*poz+1]);
}
 
 
long long query1(long long poz, long long st, long long dr, long long a, long long b)
{
    if(a<=st && dr<=b)
        return aint1[poz];
    long long mid=(st+dr)/2;
    if(b<=mid)
        return query1(2*poz,st,mid,a,b);
    if(mid<a)
        return query1(2*poz+1,mid+1,dr,a,b);
    return (query1(2*poz,st,mid,a,b)^query1(2*poz+1,mid+1,dr,a,b));
}
 
long long query2(long long poz, long long st, long long dr, long long a, long long b)
{
    if(a<=st && dr<=b)
        return aint2[poz];
    long long mid=(st+dr)/2;
    if(b<=mid)
        return query2(2*poz,st,mid,a,b);
    if(mid<a)
        return query2(2*poz+1,mid+1,dr,a,b);
    return (query2(2*poz,st,mid,a,b)^query2(2*poz+1,mid+1,dr,a,b));
}
 
 
 
 
int main()
{
    long long n,q;
    cin>>n>>q;
    for(long long i=1;i<=n;i++)
        cin>>v[i];
    build1(1,1,(n+1)/2);
    build2(1,1,n/2);
    for(long long i=0;i<q;i++)
    {
        long long cer,a,b;
        cin>>cer>>a>>b;
        if(cer==1)
        {
            if( (a%2) == 1)
                update1(1,1,(n+1)/2,a/2+1,b);
            else
                update2(1,1,n/2,a/2,b);
        }
        else
        {
            if((b-a)%2==1)
                cout<<0<<'\n';
            else if((a%2)==1)
                cout<<query1(1,1,(n+1)/2,a/2+1,b/2+1)<<'\n';
            else
                cout<<query2(1,1,n/2,a/2,b/2)<<'\n';
        }
    }
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 340 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 2 ms 340 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 2 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 2 ms 340 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 2 ms 340 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 2 ms 212 KB Output is correct
11 Correct 9 ms 468 KB Output is correct
12 Correct 9 ms 504 KB Output is correct
13 Correct 12 ms 496 KB Output is correct
14 Correct 13 ms 500 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 483 ms 7292 KB Output is correct
2 Correct 491 ms 7104 KB Output is correct
3 Correct 487 ms 7064 KB Output is correct
4 Correct 468 ms 7092 KB Output is correct
5 Correct 459 ms 7144 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 2 ms 340 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 2 ms 340 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 2 ms 212 KB Output is correct
11 Correct 9 ms 468 KB Output is correct
12 Correct 9 ms 504 KB Output is correct
13 Correct 12 ms 496 KB Output is correct
14 Correct 13 ms 500 KB Output is correct
15 Correct 483 ms 7292 KB Output is correct
16 Correct 491 ms 7104 KB Output is correct
17 Correct 487 ms 7064 KB Output is correct
18 Correct 468 ms 7092 KB Output is correct
19 Correct 459 ms 7144 KB Output is correct
20 Correct 385 ms 6596 KB Output is correct
21 Correct 405 ms 6532 KB Output is correct
22 Correct 401 ms 6604 KB Output is correct
23 Correct 513 ms 7036 KB Output is correct
24 Correct 462 ms 7144 KB Output is correct