Submission #890297

# Submission time Handle Problem Language Result Execution time Memory
890297 2023-12-21T02:24:45 Z 12345678 XORanges (eJOI19_xoranges) C++17
0 / 100
136 ms 9300 KB
#include <bits/stdc++.h>

using namespace std;

const int nx=2e5+5;
int n, q, a[nx], t, l, r, idx, vl, res;

struct segtree
{
    int d[4*nx];
    void update(int l, int r, int i, int idx, int vl)
    {
        if (idx<l||r<idx) return;
        if (l==r) return void(d[i]=vl);
        int md=(l+r)/2;
        update(l, md, 2*i, idx, vl);
        update(md+1, r, 2*i+1, idx, vl);
        d[i]=d[2*i]^d[2*i+1];
    }
    int query(int l, int r, int i, int ql, int qr)
    {
        if (qr<l||r<ql) return 0;
        if (ql<=l&&r<=qr) return d[i];
        int md=(l+r)/2;
        return query(l, md, 2*i, ql, qr)^query(md+1,r ,2*i+1, ql, qr);
    }
} odd, even;

int main()
{
    cin.tie(NULL)->sync_with_stdio(false);
    cin>>n>>q;
    for (int i=1; i<=n; i++) 
    {
        cin>>a[i];
        if (i%2==1) odd.update(1, n, 1, i, a[i]);
        else even.update(1, n, 1, i, a[i]);
    }
    while (q--)
    {
        cin>>t;
        if (t==1) 
        {
            cin>>idx>>a[idx];
            if (idx%2==1) odd.update(1, n, 1, idx ,a[idx]);
            else even.update(1, n, 1, idx, a[idx]);
        }
        else
        {
            cin>>l>>r;
            if (r-l+1%2==0) cout<<0<<'\n';
            else if (l%2==1) cout<<odd.query(1, n, 1, l, r)<<'\n';
            else cout<<even.query(1, n, 1, l, r)<<'\n';
        }
    }
}

/*
3 2 3 4 5
*/
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 4440 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 4444 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 4440 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 136 ms 9300 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 4440 KB Output isn't correct
2 Halted 0 ms 0 KB -