// This program was written on 19.05.2022
// for problem xoranges
// by Mircea Rebengiuc
#include <stdio.h>
#include <ctype.h>
#define MAXN 200000
#define MAX_HALF 100000
class AIB {
private:
int aib[1 + MAX_HALF];
int n;
public:
AIB(){}
void resize( int _n ){ n = _n; }
int query( int l, int r ){
int retval = 0;
r++;
while( r ){
retval ^= aib[r];
r &= (r - 1);
}
while( l ){
retval ^= aib[l];
l &= (l - 1);
}
return retval;
}
void update( int i, int delta ){
i++;
while( i <= n ){
aib[i] ^= delta;
i += (-i & i);
}
}
} aib[2];
int v[MAXN];
inline int query( int l, int r ){
if( (l - r) & 1 )
return 0;
return aib[l & 1].query( l >> 1, r >> 1 );
}
inline void update( int i, int newval ){
aib[i & 1].update( i >> 1, newval ^ v[i] );
v[i] = newval;
}
static inline int getint(){
int n = 0, ch;
while( !isdigit( ch = fgetc( stdin ) ) );
do
n = n * 10 + ch - '0';
while( isdigit( ch = fgetc( stdin ) ) );
return n;
}
int main(){
int n, i, q, a, b;
n = getint();
q = getint();
aib[0].resize( (n + 1) >> 1 );
aib[1].resize( n >> 1 );
for( i = 0 ; i < n ; i++ )
update( i, getint() );
for( ; q-- ; ){
switch( getint() ){
case 1:
a = getint() - 1;
b = getint();
update( a, b );
break;
case 2:
a = getint() - 1;
b = getint() - 1;
printf( "%d\n", query( a, b ) );
break;
}
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
296 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
296 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
2 ms |
436 KB |
Output is correct |
13 |
Correct |
2 ms |
468 KB |
Output is correct |
14 |
Correct |
2 ms |
468 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
50 ms |
7816 KB |
Output is correct |
2 |
Correct |
48 ms |
7840 KB |
Output is correct |
3 |
Correct |
66 ms |
7816 KB |
Output is correct |
4 |
Correct |
63 ms |
7500 KB |
Output is correct |
5 |
Correct |
50 ms |
7524 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
296 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
2 ms |
436 KB |
Output is correct |
13 |
Correct |
2 ms |
468 KB |
Output is correct |
14 |
Correct |
2 ms |
468 KB |
Output is correct |
15 |
Correct |
50 ms |
7816 KB |
Output is correct |
16 |
Correct |
48 ms |
7840 KB |
Output is correct |
17 |
Correct |
66 ms |
7816 KB |
Output is correct |
18 |
Correct |
63 ms |
7500 KB |
Output is correct |
19 |
Correct |
50 ms |
7524 KB |
Output is correct |
20 |
Correct |
42 ms |
7576 KB |
Output is correct |
21 |
Correct |
46 ms |
7560 KB |
Output is correct |
22 |
Correct |
47 ms |
7556 KB |
Output is correct |
23 |
Correct |
50 ms |
7524 KB |
Output is correct |
24 |
Correct |
47 ms |
7504 KB |
Output is correct |