Submission #979455

# Submission time Handle Problem Language Result Execution time Memory
979455 2024-05-11T04:06:26 Z LOLOLO XORanges (eJOI19_xoranges) C++17
55 / 100
16 ms 7516 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 = 1e5 + 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 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 600 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 600 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 2 ms 604 KB Output is correct
12 Correct 2 ms 604 KB Output is correct
13 Correct 2 ms 604 KB Output is correct
14 Correct 2 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 16 ms 7516 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 600 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 2 ms 604 KB Output is correct
12 Correct 2 ms 604 KB Output is correct
13 Correct 2 ms 604 KB Output is correct
14 Correct 2 ms 604 KB Output is correct
15 Runtime error 16 ms 7516 KB Execution killed with signal 11
16 Halted 0 ms 0 KB -