#include <iostream>
using namespace std;
const int nmax = 2e5;
int aib[2][nmax + 1];
int n;
int v[nmax + 1];
int lsb ( int x ) {
return x & ( -x );
}
void update ( int p, int poz, int val ) {
for ( ; poz <= n; poz += lsb ( poz ) )
aib[p][poz] ^= val;
}
int query ( int p, int poz ) {
int rez = 0;
for ( ; poz > 0; poz -= lsb ( poz ) )
rez = rez ^ aib[p][poz];
return rez;
}
int main () {
int q, t, x, y;
cin >> n >> q;
for ( int i = 1; i <= n; i++ ) {
cin >> v[i];
update ( i % 2, i, v[i] );
}
for ( int i = 1; i <= q; i++ ) {
cin >> t >> x >> y;
if ( t == 1 ) {
update ( x % 2, x, y ^ v[x] );
v[x] = y;
} else {
if ( x % 2 == y % 2 )
cout << ( query ( x % 2, x - 1 ) ^ query ( y % 2, y ) ) << '\n';
else
cout << 0 << '\n';
}
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
316 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
332 KB |
Output is correct |
2 |
Correct |
2 ms |
304 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
2 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
316 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
2 ms |
332 KB |
Output is correct |
7 |
Correct |
2 ms |
304 KB |
Output is correct |
8 |
Correct |
1 ms |
332 KB |
Output is correct |
9 |
Correct |
1 ms |
332 KB |
Output is correct |
10 |
Correct |
2 ms |
204 KB |
Output is correct |
11 |
Correct |
8 ms |
512 KB |
Output is correct |
12 |
Correct |
9 ms |
432 KB |
Output is correct |
13 |
Correct |
12 ms |
440 KB |
Output is correct |
14 |
Correct |
11 ms |
440 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
480 ms |
8716 KB |
Output is correct |
2 |
Correct |
466 ms |
8576 KB |
Output is correct |
3 |
Correct |
515 ms |
8556 KB |
Output is correct |
4 |
Correct |
464 ms |
8324 KB |
Output is correct |
5 |
Correct |
464 ms |
8352 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
316 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
2 ms |
332 KB |
Output is correct |
7 |
Correct |
2 ms |
304 KB |
Output is correct |
8 |
Correct |
1 ms |
332 KB |
Output is correct |
9 |
Correct |
1 ms |
332 KB |
Output is correct |
10 |
Correct |
2 ms |
204 KB |
Output is correct |
11 |
Correct |
8 ms |
512 KB |
Output is correct |
12 |
Correct |
9 ms |
432 KB |
Output is correct |
13 |
Correct |
12 ms |
440 KB |
Output is correct |
14 |
Correct |
11 ms |
440 KB |
Output is correct |
15 |
Correct |
480 ms |
8716 KB |
Output is correct |
16 |
Correct |
466 ms |
8576 KB |
Output is correct |
17 |
Correct |
515 ms |
8556 KB |
Output is correct |
18 |
Correct |
464 ms |
8324 KB |
Output is correct |
19 |
Correct |
464 ms |
8352 KB |
Output is correct |
20 |
Correct |
346 ms |
8356 KB |
Output is correct |
21 |
Correct |
376 ms |
8368 KB |
Output is correct |
22 |
Correct |
396 ms |
8420 KB |
Output is correct |
23 |
Correct |
458 ms |
8276 KB |
Output is correct |
24 |
Correct |
433 ms |
8252 KB |
Output is correct |