Submission #456247

# Submission time Handle Problem Language Result Execution time Memory
456247 2021-08-06T09:37:37 Z SamAnd XORanges (eJOI19_xoranges) C++17
100 / 100
214 ms 13072 KB
#include <bits/stdc++.h>
using namespace std;
#define m_p make_pair
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define fi first
#define se second
typedef long long ll;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
mt19937 rnf(2106);
const int N = 200005;

int n, qq;
int a[N];

void ubd(vector<int>& t, int tl, int tr, int x, int y, int pos)
{
    if (tl == tr)
    {
        t[pos] = y;
        return;
    }
    int m = (tl + tr) / 2;
    if (x <= m)
        ubd(t, tl, m, x, y, pos * 2);
    else
        ubd(t, m + 1, tr, x, y, pos * 2 + 1);
    t[pos] = (t[pos * 2] ^ t[pos * 2 + 1]);
}

int qry(vector<int>& t, int tl, int tr, int l, int r, int pos)
{
    if (l > r)
        return 0;
    if (tl == l && tr == r)
        return t[pos];
    int m = (tl + tr) / 2;
    return (qry(t, tl, m, l, min(m, r), pos * 2) ^
            qry(t, m + 1, tr, max(m + 1, l), r, pos * 2 + 1));
}

void solv()
{
    cin >> n >> qq;
    for (int i = 1; i <= n; ++i)
        cin >> a[i];

    vector<int> t[2];
    t[0].assign(n * 4 + 10, 0);
    t[1].assign(n * 4 + 10, 0);

    for (int i = 1; i <= n; ++i)
        ubd(t[(i % 2)], 1, n, i, a[i], 1);

    while (qq--)
    {
        int ty;
        cin >> ty;
        if (ty == 1)
        {
            int x, y;
            cin >> x >> y;
            ubd(t[(x % 2)], 1, n, x, y, 1);
        }
        else
        {
            int l, r;
            cin >> l >> r;
            if ((r - l + 1) % 2 == 0)
                cout << "0\n";
            else
                cout << qry(t[(l % 2)], 1, n, l, r, 1) << "\n";
        }
    }
}

int main()
{
    #ifdef SOMETHING
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    #endif // SOMETHING
    ios_base::sync_with_stdio(false), cin.tie(0);

    int tt = 1;
    //cin >> tt;
    while (tt--)
    {
        solv();
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 5 ms 588 KB Output is correct
12 Correct 4 ms 588 KB Output is correct
13 Correct 4 ms 588 KB Output is correct
14 Correct 4 ms 588 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 201 ms 12996 KB Output is correct
2 Correct 214 ms 12972 KB Output is correct
3 Correct 200 ms 12920 KB Output is correct
4 Correct 193 ms 13008 KB Output is correct
5 Correct 178 ms 13044 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 5 ms 588 KB Output is correct
12 Correct 4 ms 588 KB Output is correct
13 Correct 4 ms 588 KB Output is correct
14 Correct 4 ms 588 KB Output is correct
15 Correct 201 ms 12996 KB Output is correct
16 Correct 214 ms 12972 KB Output is correct
17 Correct 200 ms 12920 KB Output is correct
18 Correct 193 ms 13008 KB Output is correct
19 Correct 178 ms 13044 KB Output is correct
20 Correct 191 ms 12352 KB Output is correct
21 Correct 203 ms 12496 KB Output is correct
22 Correct 209 ms 12356 KB Output is correct
23 Correct 184 ms 13072 KB Output is correct
24 Correct 184 ms 12996 KB Output is correct