#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 |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
328 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
328 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
332 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
3 ms |
596 KB |
Output is correct |
12 |
Correct |
3 ms |
596 KB |
Output is correct |
13 |
Correct |
3 ms |
596 KB |
Output is correct |
14 |
Correct |
3 ms |
576 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
108 ms |
5576 KB |
Output is correct |
2 |
Correct |
122 ms |
10368 KB |
Output is correct |
3 |
Correct |
124 ms |
10444 KB |
Output is correct |
4 |
Correct |
111 ms |
10008 KB |
Output is correct |
5 |
Correct |
102 ms |
10108 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
328 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
332 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
3 ms |
596 KB |
Output is correct |
12 |
Correct |
3 ms |
596 KB |
Output is correct |
13 |
Correct |
3 ms |
596 KB |
Output is correct |
14 |
Correct |
3 ms |
576 KB |
Output is correct |
15 |
Correct |
108 ms |
5576 KB |
Output is correct |
16 |
Correct |
122 ms |
10368 KB |
Output is correct |
17 |
Correct |
124 ms |
10444 KB |
Output is correct |
18 |
Correct |
111 ms |
10008 KB |
Output is correct |
19 |
Correct |
102 ms |
10108 KB |
Output is correct |
20 |
Correct |
112 ms |
9912 KB |
Output is correct |
21 |
Correct |
107 ms |
10012 KB |
Output is correct |
22 |
Correct |
107 ms |
9904 KB |
Output is correct |
23 |
Correct |
104 ms |
10060 KB |
Output is correct |
24 |
Correct |
108 ms |
10024 KB |
Output is correct |