Submission #988982

# Submission time Handle Problem Language Result Execution time Memory
988982 2024-05-27T08:50:58 Z Khanhcsp2 XORanges (eJOI19_xoranges) C++14
100 / 100
97 ms 18876 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 12888 KB Output is correct
2 Correct 2 ms 12892 KB Output is correct
3 Correct 2 ms 12992 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 2 ms 12892 KB Output is correct
2 Correct 2 ms 12892 KB Output is correct
3 Correct 2 ms 12892 KB Output is correct
4 Correct 2 ms 12892 KB Output is correct
5 Correct 2 ms 12892 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 12888 KB Output is correct
2 Correct 2 ms 12892 KB Output is correct
3 Correct 2 ms 12992 KB Output is correct
4 Correct 2 ms 12892 KB Output is correct
5 Correct 2 ms 12888 KB Output is correct
6 Correct 2 ms 12892 KB Output is correct
7 Correct 2 ms 12892 KB Output is correct
8 Correct 2 ms 12892 KB Output is correct
9 Correct 2 ms 12892 KB Output is correct
10 Correct 2 ms 12892 KB Output is correct
11 Correct 4 ms 12892 KB Output is correct
12 Correct 4 ms 12992 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 97 ms 18772 KB Output is correct
2 Correct 92 ms 18768 KB Output is correct
3 Correct 91 ms 18876 KB Output is correct
4 Correct 83 ms 18596 KB Output is correct
5 Correct 88 ms 18776 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 12888 KB Output is correct
2 Correct 2 ms 12892 KB Output is correct
3 Correct 2 ms 12992 KB Output is correct
4 Correct 2 ms 12892 KB Output is correct
5 Correct 2 ms 12888 KB Output is correct
6 Correct 2 ms 12892 KB Output is correct
7 Correct 2 ms 12892 KB Output is correct
8 Correct 2 ms 12892 KB Output is correct
9 Correct 2 ms 12892 KB Output is correct
10 Correct 2 ms 12892 KB Output is correct
11 Correct 4 ms 12892 KB Output is correct
12 Correct 4 ms 12992 KB Output is correct
13 Correct 4 ms 12892 KB Output is correct
14 Correct 4 ms 12892 KB Output is correct
15 Correct 97 ms 18772 KB Output is correct
16 Correct 92 ms 18768 KB Output is correct
17 Correct 91 ms 18876 KB Output is correct
18 Correct 83 ms 18596 KB Output is correct
19 Correct 88 ms 18776 KB Output is correct
20 Correct 89 ms 18516 KB Output is correct
21 Correct 89 ms 18696 KB Output is correct
22 Correct 87 ms 18516 KB Output is correct
23 Correct 82 ms 18420 KB Output is correct
24 Correct 91 ms 18512 KB Output is correct