#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define ll long long
#define ld long double
#define all(_v) _v.begin(), _v.end()
#define sz(_v) (int)_v.size()
#define pii pair <int, int>
#define pll pair <ll, ll>
#define veci vector <int>
#define vecll vector <ll>
const int dx[4] = {1, -1, 0, 0};
const int dy[4] = {0, 0, -1, 1};
const double PI = 3.1415926535897932384626433832795;
const double eps = 1e-9;
const int MOD1 = 1e9 + 7;
const int MOD2 = 998244353;
const int MAXN = 2e5 + 10;
int t[MAXN << 2][2];
int n, q;
int a[MAXN];
void upd(int pos, int val, int v = 1, int tl = 1, int tr = n) {
if(tl == tr) {
t[v][pos & 1] = val;
return;
}
int tm = tl + tr >> 1;
if(pos <= tm) upd(pos, val, v << 1, tl, tm);
else upd(pos, val, v << 1 | 1, tm + 1, tr);
for(int j = 0; j < 2; ++j)
t[v][j] = t[v << 1][j] ^ t[v << 1 | 1][j];
}
int get(int l, int r, int v = 1, int tl = 1, int tr = n) {
if(l <= tl && tr <= r) return t[v][l & 1];
if(l > tr || r < tl) return 0;
int tm = tl + tr >> 1;
return get(l, r, v << 1, tl, tm) ^ get(l, r, v << 1 | 1, tm + 1, tr);
}
void solve() {
cin >> n >> q;
for(int i = 1; i <= n; ++i) {
cin >> a[i];
upd(i, a[i]);
}
for(int i = 1; i <= q; ++i) {
int type, l, r;
cin >> type >> l >> r;
if(type == 1) a[l] = r, upd(l, r);
else {
if((r - l) % 2) cout << "0\n";
else cout << get(l, r) << '\n';
}
}
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int T = 1;
///cin >> T;
while(T--) solve(), cout << '\n';
return 0;
}
Compilation message
xoranges.cpp: In function 'void upd(int, int, int, int, int)':
xoranges.cpp:34:17: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
34 | int tm = tl + tr >> 1;
| ~~~^~~~
xoranges.cpp: In function 'int get(int, int, int, int, int)':
xoranges.cpp:44:17: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
44 | int tm = tl + tr >> 1;
| ~~~^~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
492 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
492 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
7 |
Correct |
1 ms |
364 KB |
Output is correct |
8 |
Correct |
1 ms |
364 KB |
Output is correct |
9 |
Correct |
1 ms |
364 KB |
Output is correct |
10 |
Correct |
1 ms |
364 KB |
Output is correct |
11 |
Correct |
4 ms |
620 KB |
Output is correct |
12 |
Correct |
4 ms |
620 KB |
Output is correct |
13 |
Correct |
4 ms |
620 KB |
Output is correct |
14 |
Correct |
5 ms |
620 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
185 ms |
6508 KB |
Output is correct |
2 |
Correct |
192 ms |
11372 KB |
Output is correct |
3 |
Correct |
208 ms |
11372 KB |
Output is correct |
4 |
Correct |
160 ms |
10988 KB |
Output is correct |
5 |
Correct |
166 ms |
10920 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
492 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
7 |
Correct |
1 ms |
364 KB |
Output is correct |
8 |
Correct |
1 ms |
364 KB |
Output is correct |
9 |
Correct |
1 ms |
364 KB |
Output is correct |
10 |
Correct |
1 ms |
364 KB |
Output is correct |
11 |
Correct |
4 ms |
620 KB |
Output is correct |
12 |
Correct |
4 ms |
620 KB |
Output is correct |
13 |
Correct |
4 ms |
620 KB |
Output is correct |
14 |
Correct |
5 ms |
620 KB |
Output is correct |
15 |
Correct |
185 ms |
6508 KB |
Output is correct |
16 |
Correct |
192 ms |
11372 KB |
Output is correct |
17 |
Correct |
208 ms |
11372 KB |
Output is correct |
18 |
Correct |
160 ms |
10988 KB |
Output is correct |
19 |
Correct |
166 ms |
10920 KB |
Output is correct |
20 |
Correct |
187 ms |
10988 KB |
Output is correct |
21 |
Correct |
188 ms |
10988 KB |
Output is correct |
22 |
Correct |
184 ms |
10988 KB |
Output is correct |
23 |
Correct |
180 ms |
10988 KB |
Output is correct |
24 |
Correct |
165 ms |
10988 KB |
Output is correct |