Submission #477857

# Submission time Handle Problem Language Result Execution time Memory
477857 2021-10-04T08:16:29 Z Pragmatism XORanges (eJOI19_xoranges) C++17
0 / 100
167 ms 14596 KB
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <set>
#include <vector>
#include <cmath>
#include <map>
#include <algorithm>
#include <stack>
#include <queue>
#include <cstdlib>
#include <cstdio>
#include <cstring>

#define pb push_back
#define pob pop_back
#define pll pair <long long, long long>
#define pld pair <long double, long double>
#define ll long long
#define ull unsigned long long
#define ld long double
#define int ll
#define Int int 
#define itn int
#define nit int
#define x first
#define y second
#define all(v) v.begin(),v.end()
#define sz(s) s.size()
#define skip continue
#define equal jlij
#define y0 ijl
#define y1 hjk
#define friend trs
#define delete bae
#define div aber
#define exp earb
#define new aer
#define find find

using namespace std;

const int N = 8e5 + 7;
const int inf = 1e9 + 7;
const int INF = 1e18 + 7;



int t[N];
int t0[N];
int t1[N];
int a[N];
void build(int v, int tl, int tr) {
    if (tl == tr) {
        t[v] = a[tl];
        if (tl % 2 == 0)t0[v] = a[tl];
        else t1[v] = a[tl];
        return;
    }
    int mid = (tl + tr) / 2;
    build(v * 2, tl, mid), build(v * 2 + 1, mid + 1, tr);
    t[v] = (t[v * 2] ^ t[v * 2 + 1]);
    t0[v] = (t0[v * 2] ^ t0[v * 2 + 1]), t1[v] = (t1[v * 2] ^ t1[v * 2 + 1]);
}
int get(int v, int tl, int tr, int l, int r) {
    if (tr < l || tl > r)return 0;
    if (tl >= l && tr <= r)return t[v];
    int mid = (tl + tr) / 2;
    return (get(v * 2, tl, mid, l, r) ^ get(v * 2 + 1, mid + 1, tr, l, r));
}
int get0(int v, int tl, int tr, int l, int r) {
    if (tr < l || tl > r)return 0;
    if (tl >= l && tr <= r)return t0[v];
    int mid = (tl + tr) / 2;
    return (get(v * 2, tl, mid, l, r) ^ get(v * 2 + 1, mid + 1, tr, l, r));
}
int get1(int v, int tl, int tr, int l, int r) {
    if (tr < l || tl > r)return 0;
    if (tl >= l && tr <= r)return t1[v];
    int mid = (tl + tr) / 2;
    return (get(v * 2, tl, mid, l, r) ^ get(v * 2 + 1, mid + 1, tr, l, r));
}
void update(int v, int tl, int tr, int pos, int x) {
    if (tl == tr) {
        t[v] = x;
        if (tl % 2 == 0)t0[v] = x, t1[v] = 0;
        else t1[v] = x, t0[v] = 0;
        return;
    }
    int mid = (tl + tr) / 2;
    if (pos <= mid)update(v * 2, tl, mid, pos, x);
    else update(v * 2 + 1, mid + 1, tr, pos, x);
    t[v] = (t[v * 2] ^ t[v * 2 + 1]);
    t0[v] = (t0[v * 2] ^ t0[v * 2 + 1]), t1[v] = (t1[v * 2] ^ t1[v * 2 + 1]);
}
void solve() {
    int n, q;
    cin >> n >> q;
    for (int i = 1;i <= n;i++)cin >> a[i];
    build(1, 1, n);
    while (q--) {
        int type, l, r, pos, x;
        cin >> type;
        if (type == 1) {
            cin >> pos >> x;
            update(1, 1, n, pos, x);
        }
        else {
            cin >> l >> r;
            if ((r - l) % 2 == 1)cout << 0 << "\n";
            else {
                x = get(1, 1, n, l, r);
                if (l % 2 == 1)cout << (x ^ (get0(1, 1, n, l, r))) << "\n";
                else cout << (x ^ (get1(1, 1, n, l, r))) << "\n";
            }
        }
    }
}
signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t;
    t = 1;
    while (t--)solve();
    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 167 ms 14596 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -