Submission #986473

# Submission time Handle Problem Language Result Execution time Memory
986473 2024-05-20T15:39:14 Z alittlemiddle XORanges (eJOI19_xoranges) C++14
100 / 100
131 ms 18916 KB
#include <bits/stdc++.h>
#define el '\n'
#define fi first
#define sc second
#define int ll
#define pii pair<int, int>
#define all(v) v.begin(), v.end()
using namespace std;
using ll=long long;
using ull=unsigned long long;
using ld=long double;
const int mod=1e9+7;
const int N=2e5+11;
int n, q, x, l, r, tt;
struct segtree
{
    int nod[4*N];
    segtree()
    {
        memset(nod, 0, sizeof nod);
    }
    void update(int id, int l, int r, int pos, int val)
    {
        if(l==r)
        {
            nod[id]=val;
            return;
        }
        int mid=(l+r)/2;
        if(pos<=mid) update(id*2, l, mid, pos, val);
        else update(id*2+1, mid+1, r, pos, val);
        nod[id]=nod[id*2]^nod[id*2+1];
    }
    int get(int id, int l, int r, int u, int v)
    {
        if(r<u || v<l) return 0;
        if(u<=l && r<=v) return nod[id];
        int mid=(l+r)/2;
        return get(id*2, l, mid, u, v) ^ get(id*2+1, mid+1, r, u, v);
    }
}seg1, seg2;
void sol()
{
    cin >> n >> q;
    for(int i=1;i<=n;i++)
    {
        cin >> x;
        if(i&1) seg1.update(1, 1, n, i/2+1, x);
        else seg2.update(1, 1, n, i/2, x);
    }
    while(q--)
    {
        cin >> tt >> l >> r;
        if(tt==1)
        {
            if(l&1) seg1.update(1, 1, n, l/2+1, r);
            else seg2.update(1, 1, n, l/2, r);
        }
        else
        {
            int sz=r-l+1;
            if(sz%2==0) cout << 0 << el;
            else
            {
                if(l&1) cout << seg1.get(1, 1, n, l/2+1, l/2+1+sz/2) << el;
                else cout << seg2.get(1, 1, n, l/2, l/2+sz/2) << el;
            }
        }
    }
}
signed main()
{
//    freopen("divisor.INP", "r", stdin);
//    freopen("divisor.OUT", "w", stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int t=1;
    //cin >> t;
    while(t--)
    {
        sol();
    }
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 12892 KB Output is correct
2 Correct 2 ms 12976 KB Output is correct
3 Correct 2 ms 12888 KB Output is correct
4 Correct 2 ms 12892 KB Output is correct
5 Correct 2 ms 12888 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 12892 KB Output is correct
2 Correct 2 ms 12892 KB Output is correct
3 Correct 2 ms 12888 KB Output is correct
4 Correct 3 ms 12892 KB Output is correct
5 Correct 3 ms 12892 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 12892 KB Output is correct
2 Correct 2 ms 12976 KB Output is correct
3 Correct 2 ms 12888 KB Output is correct
4 Correct 2 ms 12892 KB Output is correct
5 Correct 2 ms 12888 KB Output is correct
6 Correct 3 ms 12892 KB Output is correct
7 Correct 2 ms 12892 KB Output is correct
8 Correct 2 ms 12888 KB Output is correct
9 Correct 3 ms 12892 KB Output is correct
10 Correct 3 ms 12892 KB Output is correct
11 Correct 4 ms 12888 KB Output is correct
12 Correct 4 ms 13096 KB Output is correct
13 Correct 4 ms 12892 KB Output is correct
14 Correct 4 ms 12892 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 109 ms 18876 KB Output is correct
2 Correct 121 ms 18772 KB Output is correct
3 Correct 131 ms 18916 KB Output is correct
4 Correct 95 ms 18608 KB Output is correct
5 Correct 97 ms 18516 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 12892 KB Output is correct
2 Correct 2 ms 12976 KB Output is correct
3 Correct 2 ms 12888 KB Output is correct
4 Correct 2 ms 12892 KB Output is correct
5 Correct 2 ms 12888 KB Output is correct
6 Correct 3 ms 12892 KB Output is correct
7 Correct 2 ms 12892 KB Output is correct
8 Correct 2 ms 12888 KB Output is correct
9 Correct 3 ms 12892 KB Output is correct
10 Correct 3 ms 12892 KB Output is correct
11 Correct 4 ms 12888 KB Output is correct
12 Correct 4 ms 13096 KB Output is correct
13 Correct 4 ms 12892 KB Output is correct
14 Correct 4 ms 12892 KB Output is correct
15 Correct 109 ms 18876 KB Output is correct
16 Correct 121 ms 18772 KB Output is correct
17 Correct 131 ms 18916 KB Output is correct
18 Correct 95 ms 18608 KB Output is correct
19 Correct 97 ms 18516 KB Output is correct
20 Correct 100 ms 18512 KB Output is correct
21 Correct 104 ms 18724 KB Output is correct
22 Correct 103 ms 18632 KB Output is correct
23 Correct 95 ms 18580 KB Output is correct
24 Correct 100 ms 18516 KB Output is correct