Submission #288414

# Submission time Handle Problem Language Result Execution time Memory
288414 2020-09-01T13:27:23 Z topovik XORanges (eJOI19_xoranges) C++14
0 / 100
173 ms 6264 KB
#include <bits/stdc++.h>

#define f first
#define s second
#define pb push_back
#define INF 1000000000

using namespace std;

typedef long long ll;
typedef long double ld;

const ll oo = 1e12;
const int N = 1e6;

int a[N];
int val[N][2];
int n,q;

void Build(int l, int r, int posx, int posy)
{
    if (l==r)
    {
        if ((l*2+posy-2)<n) val[posx][posy]=a[l*2+posy-2];
        return ;
    }
    int mdl=(l+r)>>1;
    Build(l,mdl,posx*2,posy);
    Build(mdl+1,r,posx*2+1,posy);
    val[posx][posy]=val[posx*2][posy]^val[posx*2+1][posy];
}

inline void Upd(int l, int r, int nom, int zn,int posx, int posy)
{
    if (l>nom || r<nom) return ;
    if (l==r)           {val[posx][posy]=zn;return;}
    int mdl=(l+r)>>1;
    Upd(l,mdl,nom,zn,posx*2,posy);
    Upd(mdl+1,r,nom,zn,posx*2+1,posy);
    val[posx][posy]=val[posx*2][posy]^val[posx*2+1][posy];
}

inline int Sum(int l, int r, int l1, int r1, int posx, int posy)
{
    if (l1>r1) return 0;
    if (l1==l && r1==r) return val[posx][posy];
    int mdl=(l+r)>>1;
    return Sum(l,mdl,l1,min(mdl,r1),posx<<1,posy)^Sum(mdl+1,r,max(mdl+1,l1),r1,posx<<1+1,posy);
}

int main()
{
    cin>>n>>q;
    for (int i=0; i<n; i++) cin>>a[i];
    Build(1,(n+1)>>1,1,0);
    Build(1,n>>1,1,1);
    while (q>0)
    {
        q--;
        int nom,x,y;
        cin>>nom>>x>>y;
        if (nom==1) Upd(1,(n+1)>>1,(x+1)/2,y,1,(x+1)&1);
        else
        {
            if (!((y-x+1)&1)) cout<<0<<endl;
            else              cout<<Sum(1,(n+1)/2,(x+1)/2,(y+1)/2,1,(x+1)&1)<<endl;
        }
    }
}

Compilation message

xoranges.cpp: In function 'int Sum(int, int, int, int, int, int)':
xoranges.cpp:48:87: warning: suggest parentheses around '+' inside '<<' [-Wparentheses]
   48 |     return Sum(l,mdl,l1,min(mdl,r1),posx<<1,posy)^Sum(mdl+1,r,max(mdl+1,l1),r1,posx<<1+1,posy);
      |                                                                                      ~^~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 173 ms 6264 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -