#include <bits/stdc++.h>
using namespace std;
const int nx=2e5+5;
int n, q, a[nx], t, l, r, idx, vl, res;
struct segtree
{
int d[4*nx];
void update(int l, int r, int i, int idx, int vl)
{
if (idx<l||r<idx) return;
if (l==r) return void(d[i]=vl);
int md=(l+r)/2;
update(l, md, 2*i, idx, vl);
update(md+1, r, 2*i+1, idx, vl);
d[i]=d[2*i]^d[2*i+1];
}
int query(int l, int r, int i, int ql, int qr)
{
if (qr<l||r<ql) return 0;
if (ql<=l&&r<=qr) return d[i];
int md=(l+r)/2;
return query(l, md, 2*i, ql, qr)^query(md+1, r ,2*i+1, ql, qr);
}
} odd, even;
int main()
{
cin.tie(NULL)->sync_with_stdio(false);
cin>>n>>q;
for (int i=1; i<=n; i++)
{
cin>>a[i];
if (i%2==1) odd.update(1, n, 1, i, a[i]);
else even.update(1, n, 1, i, a[i]);
}
while (q--)
{
cin>>t;
if (t==1)
{
cin>>idx>>a[idx];
if (idx%2==1) odd.update(1, n, 1, idx ,a[idx]);
else even.update(1, n, 1, idx, a[idx]);
}
else
{
cin>>l>>r;
if ((r-l+1)%2==0) cout<<0<<'\n';
else if (l%2==1) cout<<odd.query(1, n, 1, l, r)<<'\n';
else cout<<even.query(1, n, 1, l, r)<<'\n';
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
4444 KB |
Output is correct |
2 |
Correct |
1 ms |
4444 KB |
Output is correct |
3 |
Correct |
1 ms |
4444 KB |
Output is correct |
4 |
Correct |
1 ms |
4440 KB |
Output is correct |
5 |
Correct |
1 ms |
4444 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
4444 KB |
Output is correct |
2 |
Correct |
1 ms |
4444 KB |
Output is correct |
3 |
Correct |
2 ms |
4444 KB |
Output is correct |
4 |
Correct |
1 ms |
4444 KB |
Output is correct |
5 |
Correct |
1 ms |
4444 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
4444 KB |
Output is correct |
2 |
Correct |
1 ms |
4444 KB |
Output is correct |
3 |
Correct |
1 ms |
4444 KB |
Output is correct |
4 |
Correct |
1 ms |
4440 KB |
Output is correct |
5 |
Correct |
1 ms |
4444 KB |
Output is correct |
6 |
Correct |
1 ms |
4444 KB |
Output is correct |
7 |
Correct |
1 ms |
4444 KB |
Output is correct |
8 |
Correct |
2 ms |
4444 KB |
Output is correct |
9 |
Correct |
1 ms |
4444 KB |
Output is correct |
10 |
Correct |
1 ms |
4444 KB |
Output is correct |
11 |
Correct |
3 ms |
4700 KB |
Output is correct |
12 |
Correct |
3 ms |
4700 KB |
Output is correct |
13 |
Correct |
3 ms |
4700 KB |
Output is correct |
14 |
Correct |
3 ms |
4700 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
105 ms |
8660 KB |
Output is correct |
2 |
Correct |
113 ms |
13396 KB |
Output is correct |
3 |
Correct |
108 ms |
13396 KB |
Output is correct |
4 |
Correct |
102 ms |
12952 KB |
Output is correct |
5 |
Correct |
109 ms |
13200 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
4444 KB |
Output is correct |
2 |
Correct |
1 ms |
4444 KB |
Output is correct |
3 |
Correct |
1 ms |
4444 KB |
Output is correct |
4 |
Correct |
1 ms |
4440 KB |
Output is correct |
5 |
Correct |
1 ms |
4444 KB |
Output is correct |
6 |
Correct |
1 ms |
4444 KB |
Output is correct |
7 |
Correct |
1 ms |
4444 KB |
Output is correct |
8 |
Correct |
2 ms |
4444 KB |
Output is correct |
9 |
Correct |
1 ms |
4444 KB |
Output is correct |
10 |
Correct |
1 ms |
4444 KB |
Output is correct |
11 |
Correct |
3 ms |
4700 KB |
Output is correct |
12 |
Correct |
3 ms |
4700 KB |
Output is correct |
13 |
Correct |
3 ms |
4700 KB |
Output is correct |
14 |
Correct |
3 ms |
4700 KB |
Output is correct |
15 |
Correct |
105 ms |
8660 KB |
Output is correct |
16 |
Correct |
113 ms |
13396 KB |
Output is correct |
17 |
Correct |
108 ms |
13396 KB |
Output is correct |
18 |
Correct |
102 ms |
12952 KB |
Output is correct |
19 |
Correct |
109 ms |
13200 KB |
Output is correct |
20 |
Correct |
104 ms |
13136 KB |
Output is correct |
21 |
Correct |
102 ms |
13140 KB |
Output is correct |
22 |
Correct |
133 ms |
13140 KB |
Output is correct |
23 |
Correct |
102 ms |
13176 KB |
Output is correct |
24 |
Correct |
102 ms |
13136 KB |
Output is correct |