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 <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <cstring>
#include <queue>
#include <map>
#include <cmath>
#include <iomanip>
using namespace std;
#define ff first
#define sc second
#define pb push_back
#define ll long long
#define pll pair<ll, ll>
#define pii pair <int, int>
#define ull unsigned long long
// #define int long long
// #define int unsigned long long
const ll inf = 1e9 + 7;
const ll weirdMod = 998244353;
int t[800040][2];
void update(int v, int tl, int tr, int pos, int val) {
if (tl == tr) {
t[v][pos & 1] = val;
return;
} int tm = (tl + tr) / 2;
if (pos <= tm)
update(2 * v, tl, tm, pos, val);
else update(2 * v + 1, tm + 1, tr, pos, val);
t[v][0] = (t[2 * v][0] ^ t[2 * v + 1][0]);
t[v][1] = (t[2 * v][1] ^ t[2 * v + 1][1]);
}
int getans(int v, int tl, int tr, int l, int r, int idx) {
if (l > r) return 0;
if (tl == l && tr == r)
return t[v][idx];
int tm = (tl + tr) / 2;
return (getans(2 * v, tl, tm, l, min(r, tm), idx) ^
getans(2 * v + 1, tm + 1, tr, max(l, tm + 1), r, idx));
}
void solve() {
int n, q;
cin >> n >> q;
for (int i = 1, x; i <= n; i++) {
cin >> x;
update(1, 1, n, i, x);
} int tc, l, r;
for (int i = 1; i <= q; i++) {
cin >> tc >> l >> r;
if (tc == 1) update(1, 1, n, l, r);
else {
if ((r - l + 1) % 2 == 0)
cout << "0\n";
else cout << getans(1, 1, n, l, r, l & 1) << '\n';
}
}
}
int32_t main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr); cout.tie(nullptr);
int t = 1;
// cin >> t;
while (t--) {
solve();
cout << '\n';
}
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... |