This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |