#include <bits/stdc++.h>
using namespace std;
int n,q;
int aintpar[200005];
int aintimpar[200005];
void update(int nod,int l,int r,int pos,int val)
{
if (l == r)
{
if (l % 2 == 1)
aintimpar[nod] = val;
else
aintpar[nod] = val;
return;
}
int mij = (l + r) / 2;
if (pos <= mij)
update(2 * nod,l,mij,pos,val);
else
update(2 * nod + 1,mij + 1,r,pos,val);
aintpar[nod] = aintpar[2 * nod] ^ aintpar[2 * nod + 1];
aintimpar[nod] = aintimpar[2 * nod] ^ aintimpar[2 * nod + 1];
}
int querypar(int nod,int l,int r,int st,int dr)
{
if (r < st or dr < l)
return 0;
if (st <= l and r <= dr)
return aintpar[nod];
int mij = (l + r) / 2;
return querypar(2 * nod,l,mij,st,dr) ^ querypar(2 * nod + 1,mij + 1,r,st,dr);
}
int queryimpar(int nod,int l,int r,int st,int dr)
{
if (r < st or dr < l)
return 0;
if (st <= l and r <= dr)
return aintimpar[nod];
int mij = (l + r) / 2;
return queryimpar(2 * nod,l,mij,st,dr) ^ queryimpar(2 * nod + 1,mij + 1,r,st,dr);
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
cin >> n >> q;
for (int i = 1; i <= n; i++)
{
int x;
cin >> x;
update(1,1,n,i,x);
}
for (int i = 1; i <= q; i++)
{
int tip,x,y;
cin >> tip >> x >> y;
if (tip == 1)
update(1,1,n,x,y);
else
{
if (y % 2 != x % 2)
cout << 0 << '\n';
else if (x % 2 == 0)
cout << querypar(1,1,n,x,y) << '\n';
else
cout << queryimpar(1,1,n,x,y) << '\n';
}
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
0 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 |
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 |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 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 |
4 ms |
596 KB |
Output is correct |
12 |
Correct |
3 ms |
596 KB |
Output is correct |
13 |
Correct |
3 ms |
592 KB |
Output is correct |
14 |
Correct |
3 ms |
596 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
468 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 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 |
4 ms |
596 KB |
Output is correct |
12 |
Correct |
3 ms |
596 KB |
Output is correct |
13 |
Correct |
3 ms |
592 KB |
Output is correct |
14 |
Correct |
3 ms |
596 KB |
Output is correct |
15 |
Runtime error |
1 ms |
468 KB |
Execution killed with signal 11 |
16 |
Halted |
0 ms |
0 KB |
- |