Submission #477822

# Submission time Handle Problem Language Result Execution time Memory
477822 2021-10-04T03:35:13 Z chungdinh XORanges (eJOI19_xoranges) C++14
55 / 100
13 ms 3532 KB
#include <iostream>
#include <vector>
#include <bitset>
#include <queue>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <stack>
#include <set>
#include <map>
#include <cassert>
#include <bits/stdc++.h>

using namespace std;

#define pb push_back

#define ll long long
#define ii pair<int,int>
#define pll pair<long long, long long>
#define fi first
#define se second
#define r first
#define c second

#define all(x) x.begin(), x.end()

ostream& operator << (ostream& os, pair<int, int> a) {
    return os << a.first << " : " << a.second;
}

#define endl '\n'
#define db(val) "["#val" = "<<(val)<<"] "
#define cntbit(x) __builtin_popcount(x)

const int N = 1e5 + 5;
const int iINF = 1e9;
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll INF = 1e18;

int n, q;

ll L1[N], L2[N];
ll get(ll bit[N], int v) {
    ll res = 0;
    for (; v >= 1; v -= v & -v) res ^= bit[v];
    return res;
}
ll point(ll bit[N], int v) {return get(bit, v) ^ get(bit, v - 1);}
ll range(ll bit[N], int l, int r) {return get(bit, r) ^ get(bit, l - 1);}
void upd(ll bit[N], int v, ll val) {
    ll old = point(bit, v);
    for (; v <= n; v += v & -v) {
        bit[v] ^= old;
        bit[v] ^= val;
    }
}

void query1(int v, ll val) {
    if (v & 1) upd(L1, v, val);
    else upd(L2, v, val);
}

ll query2(int l, int r) {
    int len = r - l + 1;

    if (len & 1) {
        if (l & 1) return range(L1, l, r);
        else return range(L2, l, r);
    } else return 0;
}

int main() {
    #ifdef CHUNGDINH
    freopen("main.inp","r",stdin);
    //freopen("main.out","w",stdout);
    #endif

    memset(L1, 0ll, sizeof L1);
    memset(L2, 0ll, sizeof L2);

    cin >> n >> q;
    for (int i = 1; i <= n; i++) {
        ll tt; cin >> tt;
        if (i & 1) upd(L1, i, tt); else upd(L2, i, tt);
    }

    while (q--) {
        int k; cin >> k;

        if (k == 1) {
            int v, val; cin >> v >> val;
            query1(v, val);
        } else {
            int l, r; cin >> l >> r;
            cout << query2(l, r) << endl;
        }
    }
}

/*
Array bounds *
long long vs int
Garbage value
Sometimes, VNOI views "arrays out of bounds" as "wrong answer"
*/
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1740 KB Output is correct
2 Correct 1 ms 1740 KB Output is correct
3 Correct 1 ms 1740 KB Output is correct
4 Correct 1 ms 1740 KB Output is correct
5 Correct 1 ms 1740 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 1740 KB Output is correct
2 Correct 2 ms 1740 KB Output is correct
3 Correct 2 ms 1740 KB Output is correct
4 Correct 2 ms 1868 KB Output is correct
5 Correct 2 ms 1740 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1740 KB Output is correct
2 Correct 1 ms 1740 KB Output is correct
3 Correct 1 ms 1740 KB Output is correct
4 Correct 1 ms 1740 KB Output is correct
5 Correct 1 ms 1740 KB Output is correct
6 Correct 3 ms 1740 KB Output is correct
7 Correct 2 ms 1740 KB Output is correct
8 Correct 2 ms 1740 KB Output is correct
9 Correct 2 ms 1868 KB Output is correct
10 Correct 2 ms 1740 KB Output is correct
11 Correct 12 ms 1868 KB Output is correct
12 Correct 11 ms 1868 KB Output is correct
13 Correct 13 ms 1868 KB Output is correct
14 Correct 13 ms 1888 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 3 ms 3532 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1740 KB Output is correct
2 Correct 1 ms 1740 KB Output is correct
3 Correct 1 ms 1740 KB Output is correct
4 Correct 1 ms 1740 KB Output is correct
5 Correct 1 ms 1740 KB Output is correct
6 Correct 3 ms 1740 KB Output is correct
7 Correct 2 ms 1740 KB Output is correct
8 Correct 2 ms 1740 KB Output is correct
9 Correct 2 ms 1868 KB Output is correct
10 Correct 2 ms 1740 KB Output is correct
11 Correct 12 ms 1868 KB Output is correct
12 Correct 11 ms 1868 KB Output is correct
13 Correct 13 ms 1868 KB Output is correct
14 Correct 13 ms 1888 KB Output is correct
15 Runtime error 3 ms 3532 KB Execution killed with signal 11
16 Halted 0 ms 0 KB -