#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define SZ(x) (int)(x.size())
#define F0(i,n) for(int i=0;i<n;i++)
#define F1(i,n) for(int i=1;i<=n;i++)
#define CL(a,x) memset(x, a, sizeof(x));
#define PR(x) cerr << #x << "=" << (x) << endl;
const int inf = 1000000009;
const double pi = atan(1.0)*4.0;
const double eps = 1e-8;
const int N = 200001;
int i, j, k, m, n;
int a[N];
int h[2][N];
void add(int ind, int x, int val) {
while (x <= n/2+1) {
h[ind][x] ^= val;
x = (x|(x-1)) + 1;
}
}
int get(int ind, int x) {
int ret = 0;
while (x) {
ret ^= h[ind][x];
x &= (x-1);
}
return ret;
}
int main() {
//freopen("x.in", "r", stdin);
int q, t;
cin >> n >> q;
F1(i, n) {
scanf("%d", &a[i]);
add(i % 2, (i + 1) / 2, a[i]);
}
while (q--) {
scanf("%d%d%d", &t, &i, &j);
if (t == 1) {
add(i % 2, (i + 1) / 2, a[i]);
a[i] = j;
add(i % 2, (i + 1) / 2, a[i]);
} else {
int len = j - i + 1;
int ret = 0;
if (len % 2) {
ret = get(j % 2, (j + 1) / 2) ^ get(i % 2, (i - 1) / 2);
}
printf("%d\n", ret);
}
}
return 0;
}
Compilation message
xoranges.cpp: In function 'int main()':
xoranges.cpp:38:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d", &a[i]);
~~~~~^~~~~~~~~~~~~
xoranges.cpp:42:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d%d%d", &t, &i, &j);
~~~~~^~~~~~~~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
4 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
4 ms |
384 KB |
Output is correct |
5 |
Correct |
5 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
5 ms |
384 KB |
Output is correct |
5 |
Correct |
5 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
4 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
4 ms |
384 KB |
Output is correct |
5 |
Correct |
5 ms |
384 KB |
Output is correct |
6 |
Correct |
5 ms |
384 KB |
Output is correct |
7 |
Correct |
5 ms |
384 KB |
Output is correct |
8 |
Correct |
5 ms |
384 KB |
Output is correct |
9 |
Correct |
5 ms |
384 KB |
Output is correct |
10 |
Correct |
5 ms |
384 KB |
Output is correct |
11 |
Correct |
8 ms |
384 KB |
Output is correct |
12 |
Correct |
7 ms |
384 KB |
Output is correct |
13 |
Correct |
8 ms |
384 KB |
Output is correct |
14 |
Correct |
7 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
146 ms |
3060 KB |
Output is correct |
2 |
Correct |
141 ms |
3036 KB |
Output is correct |
3 |
Correct |
150 ms |
3064 KB |
Output is correct |
4 |
Correct |
132 ms |
3140 KB |
Output is correct |
5 |
Correct |
132 ms |
3068 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
4 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
4 ms |
384 KB |
Output is correct |
5 |
Correct |
5 ms |
384 KB |
Output is correct |
6 |
Correct |
5 ms |
384 KB |
Output is correct |
7 |
Correct |
5 ms |
384 KB |
Output is correct |
8 |
Correct |
5 ms |
384 KB |
Output is correct |
9 |
Correct |
5 ms |
384 KB |
Output is correct |
10 |
Correct |
5 ms |
384 KB |
Output is correct |
11 |
Correct |
8 ms |
384 KB |
Output is correct |
12 |
Correct |
7 ms |
384 KB |
Output is correct |
13 |
Correct |
8 ms |
384 KB |
Output is correct |
14 |
Correct |
7 ms |
384 KB |
Output is correct |
15 |
Correct |
146 ms |
3060 KB |
Output is correct |
16 |
Correct |
141 ms |
3036 KB |
Output is correct |
17 |
Correct |
150 ms |
3064 KB |
Output is correct |
18 |
Correct |
132 ms |
3140 KB |
Output is correct |
19 |
Correct |
132 ms |
3068 KB |
Output is correct |
20 |
Correct |
141 ms |
2552 KB |
Output is correct |
21 |
Correct |
139 ms |
2424 KB |
Output is correct |
22 |
Correct |
138 ms |
2424 KB |
Output is correct |
23 |
Correct |
138 ms |
3064 KB |
Output is correct |
24 |
Correct |
137 ms |
3064 KB |
Output is correct |