Submission #1344811

#TimeUsernameProblemLanguageResultExecution timeMemory
1344811iamhereforfunXORanges (eJOI19_xoranges)C++20
100 / 100
57 ms14068 KiB
// Starcraft 2 enjoyer //

#include <bits/stdc++.h>

// #pragma GCC target("avx2")
// #pragma GCC optimize("O3")
// #pragma GCC optimize("unroll-loops")

using namespace std;

#define LSOne(X) ((X) & -(X))

const int N = 1e6 + 5;
const int M = 1e6 + 5;
const int K = 20;
const int LG = 21;
const long long INF = 1e18 + 5;
const int C = 26;
const int B = 1000;
const int MOD = 998244353;

struct Fenwick
{
    vector<int> ft;
    int n;
    Fenwick(int len)
    {
        n = len;
        ft.assign(n + 1, 0);
    }
    void update(int pos, int val)
    {
        while (pos <= n)
        {
            ft[pos] ^= val;
            pos += LSOne(pos);
        }
    }
    int get(int pos)
    {
        int sum = 0;
        while (pos > 0)
        {
            sum ^= ft[pos];
            pos -= LSOne(pos);
        }
        return sum;
    }
    int get(int l, int r)
    {
        return get(r) ^ get(l - 1);
    }
} ft(N), o(N), e(N);

int n, q, a[N];

inline void solve()
{
    cin >> n >> q;
    for (int x = 1; x <= n; x++)
    {
        cin >> a[x];
        ft.update(x, a[x]);
        if (x % 2 == 1)
            o.update(x, a[x]);
        else
            e.update(x, a[x]);
    }
    for (int x = 0; x < q; x++)
    {
        int t;
        cin >> t;
        if (t == 1)
        {
            int p, v;
            cin >> p >> v;
            ft.update(p, a[p]);
            if (p % 2 == 1)
            {
                o.update(p, a[p]);
            }
            else
            {
                e.update(p, a[p]);
            }
            a[p] = v;
            ft.update(p, a[p]);
            if (p % 2 == 1)
            {
                o.update(p, a[p]);
            }
            else
            {
                e.update(p, a[p]);
            }
        }
        else
        {
            int l, r;
            cin >> l >> r;
            if ((r - l) % 2 == 1)
                cout << 0 << "\n";
            else
            {
                if (l % 2 == 1)
                    cout << (ft.get(l, r) ^ e.get(l, r)) << "\n";
                else
                    cout << (ft.get(l, r) ^ o.get(l, r)) << "\n";
            }
        }
    }
}

signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    // cin >> t;
    for (int x = 1; x <= t; x++)
    {
        solve();
    }
    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...