//
#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 << (query(a, (a + b) / 2, a % 2) ^ query((a + b) / 2 + 1, b, b % 2)) << '\n';
}
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
2252 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
2380 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
2252 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
158 ms |
5872 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
2252 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |