#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int nx=2e5+5;
ll n, q, a[nx], t, l, r, idx, vl, res;
struct segtree
{
ll d[4*nx];
void update(int l, int r, int i, int idx, ll 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];
}
ll 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 |
Incorrect |
1 ms |
2392 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
2396 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
2392 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
142 ms |
14416 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
2392 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |