Submission #497197

# Submission time Handle Problem Language Result Execution time Memory
497197 2021-12-22T16:39:09 Z Karabasan XORanges (eJOI19_xoranges) C++17
100 / 100
120 ms 9036 KB
#include <bits/stdc++.h>

using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC target("fma,sse,sse4,avx")
#pragma GCC optimize("unroll-loops")
#define fast1 ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl "\n"
int n,q;
int tek[100005];
int cift[100005];
int seg1[400005];
int seg2[400005];
int u;
int y;
void build(int x,int bas,int son)
{
    if(bas==son)
    {
        seg1[x]=tek[bas];
        return;
    }
    int orta=(bas+son)/2;
    build(2*x,bas,orta);
    build(2*x+1,orta+1,son);
    seg1[x]=seg1[2*x]^seg1[2*x+1];
}
void build2(int x,int bas,int son)
{
    if(bas==son)
    {
        seg2[x]=cift[bas];
        return;
    }
    int orta=(bas+son)/2;
    build2(2*x,bas,orta);
    build2(2*x+1,orta+1,son);
    seg2[x]=seg2[2*x]^seg2[2*x+1];
}
void update(int x,int bas,int son,int ind,int val)
{
    if(bas==son)
    {
        seg1[x]=val;
        return;
    }
    int orta=(bas+son)/2;
    if(ind<=orta)
        update(2*x,bas,orta,ind,val);
    else
        update(2*x+1,orta+1,son,ind,val);
    seg1[x]=seg1[2*x]^seg1[2*x+1];
}
void update2(int x,int bas,int son,int ind,int val)
{
    if(bas==son)
    {
        seg2[x]=val;
        return;
    }
    int orta=(bas+son)/2;
    if(ind<=orta)
        update2(2*x,bas,orta,ind,val);
    else
        update2(2*x+1,orta+1,son,ind,val);
    seg2[x]=seg2[2*x]^seg2[2*x+1];
}
int query(int x,int bas,int son,int l,int r)
{
    if(bas>r||son<l)
        return 0;
    if(bas>=l&&son<=r)
        return seg1[x];
    int orta=(bas+son)/2;
    return query(2*x,bas,orta,l,r)^query(2*x+1,orta+1,son,l,r);
}
int query2(int x,int bas,int son,int l,int r)
{
    if(bas>r||son<l)
        return 0;
    if(bas>=l&&son<=r)
        return seg2[x];
    int orta=(bas+son)/2;
    return query2(2*x,bas,orta,l,r)^query2(2*x+1,orta+1,son,l,r);
}
void solve()
{
    cin>>n>>q;
    for(int i=1;i<=n;i++)
    {
        if(i%2==1)
            cin>>tek[++u];
        else cin>>cift[++y];
    }
    build(1,1,u);
    build2(1,1,y);
    while(q--)
    {
        int a,b,c;
        cin>>a>>b>>c;
        if(a==1)
        {
            if(b%2==1)
                update(1,1,u,(b+1)/2,c);
            else update2(1,1,y,b/2,c);
        }
        else
        {
            if((c-b)%2==1)
                cout<<0<<endl;
            else
            {
                if(b%2==1)
                    cout<<query(1,1,u,(b+1)/2,(b+1)/2+(c-b)/2)<<endl;
                else
                    cout<<query2(1,1,y,b/2,b/2+(c-b)/2)<<endl;
            }
        }
    }
}
signed main()
{
    fast1;
    int t=1;
    while(t--)
    {
        solve();
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 1 ms 324 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 0 ms 332 KB Output is correct
5 Correct 0 ms 336 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 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 0 ms 332 KB Output is correct
2 Correct 1 ms 324 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 0 ms 332 KB Output is correct
5 Correct 0 ms 336 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 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 464 KB Output is correct
12 Correct 5 ms 468 KB Output is correct
13 Correct 3 ms 464 KB Output is correct
14 Correct 3 ms 468 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 113 ms 4328 KB Output is correct
2 Correct 116 ms 4292 KB Output is correct
3 Correct 120 ms 4372 KB Output is correct
4 Correct 102 ms 4236 KB Output is correct
5 Correct 95 ms 4292 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 1 ms 324 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 0 ms 332 KB Output is correct
5 Correct 0 ms 336 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 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 464 KB Output is correct
12 Correct 5 ms 468 KB Output is correct
13 Correct 3 ms 464 KB Output is correct
14 Correct 3 ms 468 KB Output is correct
15 Correct 113 ms 4328 KB Output is correct
16 Correct 116 ms 4292 KB Output is correct
17 Correct 120 ms 4372 KB Output is correct
18 Correct 102 ms 4236 KB Output is correct
19 Correct 95 ms 4292 KB Output is correct
20 Correct 116 ms 8804 KB Output is correct
21 Correct 115 ms 9036 KB Output is correct
22 Correct 114 ms 8908 KB Output is correct
23 Correct 108 ms 8816 KB Output is correct
24 Correct 98 ms 8808 KB Output is correct