Submission #464897

# Submission time Handle Problem Language Result Execution time Memory
464897 2021-08-14T12:03:16 Z ewirlan XORanges (eJOI19_xoranges) C++17
100 / 100
125 ms 5188 KB
//

#define _CTR_SECURE_NO_WARNINGS
#include <iostream>
typedef long long int ll;
template <typename T> T in()
{
    T x;
    std::cin >> x;
    return x;
}
constexpr int maxn = 1 << 18;
int tree[maxn * 2][2];
int query(int a, int b, int p)
{
    a += maxn - 1;
    b += maxn + 1;
    int odp(0);
    while (a + 1 != b)
    {
        if (!(a & 1))odp ^= tree[a + 1][p];
        if (b & 1)odp ^= tree[b - 1][p];
        a /= 2;
        b /= 2;
    }
    return odp;
}
int main()
{
    std::cin.tie(nullptr); std::cout.tie(nullptr); std::ios_base::sync_with_stdio(0);
    int n(in<int>()), q(in<int>());
    for (int i(maxn + 1); i <= maxn + n; ++i)std::cin >> tree[i][i % 2];
    for (int i(maxn - 1); i; --i)tree[i][0] = tree[i * 2][0] ^ tree[i * 2 + 1][0];
    for (int i(maxn - 1); i; --i)tree[i][1] = tree[i * 2][1] ^ tree[i * 2 + 1][1];
    for (int j(0); j < q; ++j)
    {
        if (in<int>() == 1)
        {
            int g(maxn + in<int>());
            bool p(g % 2);
            tree[g][p] = in<int>();
            while (g /= 2)tree[g][p] = tree[g * 2][p] ^ tree[g * 2 + 1][p];
        }
        else
        {
            int a(in<int>()), b(in<int>());
            if (a % 2 == b % 2)std::cout << query(a, b, a % 2) << '\n';
            else std::cout << 0 << '\n';
        }
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2252 KB Output is correct
2 Correct 2 ms 2356 KB Output is correct
3 Correct 2 ms 2252 KB Output is correct
4 Correct 3 ms 2252 KB Output is correct
5 Correct 2 ms 2252 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2380 KB Output is correct
2 Correct 2 ms 2380 KB Output is correct
3 Correct 2 ms 2252 KB Output is correct
4 Correct 3 ms 2380 KB Output is correct
5 Correct 2 ms 2380 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2252 KB Output is correct
2 Correct 2 ms 2356 KB Output is correct
3 Correct 2 ms 2252 KB Output is correct
4 Correct 3 ms 2252 KB Output is correct
5 Correct 2 ms 2252 KB Output is correct
6 Correct 2 ms 2380 KB Output is correct
7 Correct 2 ms 2380 KB Output is correct
8 Correct 2 ms 2252 KB Output is correct
9 Correct 3 ms 2380 KB Output is correct
10 Correct 2 ms 2380 KB Output is correct
11 Correct 6 ms 2380 KB Output is correct
12 Correct 5 ms 2380 KB Output is correct
13 Correct 5 ms 2380 KB Output is correct
14 Correct 5 ms 2380 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 124 ms 5052 KB Output is correct
2 Correct 124 ms 5148 KB Output is correct
3 Correct 120 ms 5108 KB Output is correct
4 Correct 113 ms 5188 KB Output is correct
5 Correct 116 ms 5088 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2252 KB Output is correct
2 Correct 2 ms 2356 KB Output is correct
3 Correct 2 ms 2252 KB Output is correct
4 Correct 3 ms 2252 KB Output is correct
5 Correct 2 ms 2252 KB Output is correct
6 Correct 2 ms 2380 KB Output is correct
7 Correct 2 ms 2380 KB Output is correct
8 Correct 2 ms 2252 KB Output is correct
9 Correct 3 ms 2380 KB Output is correct
10 Correct 2 ms 2380 KB Output is correct
11 Correct 6 ms 2380 KB Output is correct
12 Correct 5 ms 2380 KB Output is correct
13 Correct 5 ms 2380 KB Output is correct
14 Correct 5 ms 2380 KB Output is correct
15 Correct 124 ms 5052 KB Output is correct
16 Correct 124 ms 5148 KB Output is correct
17 Correct 120 ms 5108 KB Output is correct
18 Correct 113 ms 5188 KB Output is correct
19 Correct 116 ms 5088 KB Output is correct
20 Correct 125 ms 4468 KB Output is correct
21 Correct 119 ms 4452 KB Output is correct
22 Correct 120 ms 4420 KB Output is correct
23 Correct 115 ms 4988 KB Output is correct
24 Correct 114 ms 4932 KB Output is correct