Submission #979456

# Submission time Handle Problem Language Result Execution time Memory
979456 2024-05-11T04:06:52 Z LOLOLO XORanges (eJOI19_xoranges) C++17
100 / 100
79 ms 10536 KB
#include <bits/stdc++.h>
#define ll long long
using namespace std;
 
#define           f     first
#define           s     second
#define           pb    push_back
#define           ep    emplace
#define           eb    emplace_back
#define           lb    lower_bound
#define           ub    upper_bound
#define       all(x)    x.begin(), x.end()
#define      rall(x)    x.rbegin(), x.rend()
#define   uniquev(v)    sort(all(v)), (v).resize(unique(all(v)) - (v).begin())
#define     mem(f,x)    memset(f , x , sizeof(f))
#define        sz(x)    (int)(x).size()
#define  __lcm(a, b)    (1ll * ((a) / __gcd((a), (b))) * (b))
#define          mxx    *max_element
#define          mnn    *min_element
#define    cntbit(x)    __builtin_popcountll(x)
#define       len(x)    (int)(x.length())
 
const int N = 3e5 + 10;

struct fen{
    vector <ll> f;
    int N;
    void ass(int n) {
        N = n + 100;
        f.assign(N + 1, 0);
    }

    void upd(int i, ll x) {
        for (;i; i -= i & (-i))
            f[i] ^= x;
    }

    ll get(int i) {
        ll s = 0;
        for (; i <= N; i += i & (-i))
            s ^= f[i];

        return s;
    }
};

int a[N];

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int n, q;
    cin >> n >> q;

    fen f1, f0;
    f1.ass(n + 1);
    f0.ass(n + 1);

    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        if (i % 2) {
            f1.upd(i, a[i]);
        } else {
            f0.upd(i, a[i]);
        }
    }

    for (int i = 1; i <= q; i++) {
        int t, x, y;
        cin >> t >> x >> y;
        if (t == 1) {
            if (x % 2) {
                f1.upd(x, y ^ a[x]);
            } else {
                f0.upd(x, y ^ a[x]);
            }

            a[x] = y;
        }

        if (t == 2) {
            if ((y - x + 1) % 2 == 0) {
                cout << 0 << '\n';
                continue;
            }

            if (x % 2) {
                cout << (f1.get(x) ^ f1.get(y + 1)) << '\n';
            } else {
                cout << (f0.get(x) ^ f0.get(y + 1)) << '\n';
            }
        }
    }
}  
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 2 ms 348 KB Output is correct
12 Correct 2 ms 348 KB Output is correct
13 Correct 2 ms 348 KB Output is correct
14 Correct 2 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 68 ms 9048 KB Output is correct
2 Correct 69 ms 10396 KB Output is correct
3 Correct 79 ms 10536 KB Output is correct
4 Correct 64 ms 10060 KB Output is correct
5 Correct 75 ms 10064 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 2 ms 348 KB Output is correct
12 Correct 2 ms 348 KB Output is correct
13 Correct 2 ms 348 KB Output is correct
14 Correct 2 ms 348 KB Output is correct
15 Correct 68 ms 9048 KB Output is correct
16 Correct 69 ms 10396 KB Output is correct
17 Correct 79 ms 10536 KB Output is correct
18 Correct 64 ms 10060 KB Output is correct
19 Correct 75 ms 10064 KB Output is correct
20 Correct 68 ms 10064 KB Output is correct
21 Correct 65 ms 10016 KB Output is correct
22 Correct 63 ms 10064 KB Output is correct
23 Correct 64 ms 9968 KB Output is correct
24 Correct 64 ms 10068 KB Output is correct