/* :) */
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ll long long
#define pll pair<ll, ll>
const int sz = 2e5+5;
ll a[sz], b[sz], t[sz], t1[sz];
void build(ll v, ll l, ll r)
{
if (l == r){
t[v] = a[l];
t1[v] = b[l];
return;
}
ll m = (l + r)/2;
build(v*2, l, m);
build(v*2+1, m+1, r);
t[v] = t[v*2] ^ t[v*2+1];
t1[v] = t1[v*2] ^ t1[v*2+1];
}
void update(ll v, ll l, ll r, ll ind, ll val)
{
if (l == r){
t[v] = val;
return;
}
ll m = (l + r)/2;
if (ind <= m){
update(v*2, l, m, ind, val);
}
else {
update(v*2+1, m+1, r, ind, val);
}
t[v] = t[v*2] ^ t[v*2+1];
}
void update1(ll v, ll l, ll r, ll ind, ll val)
{
if (l == r){
t1[v] = val;
return;
}
ll m = (l + r)/2;
if (ind <= m){
update1(v*2, l, m, ind, val);
}
else {
update1(v*2+1, m+1, r, ind, val);
}
t1[v] = t1[v*2] ^ t1[v*2+1];
}
ll ans(ll v, ll l, ll r, ll tl, ll tr)
{
if (l>tr or r<tl) return 0;
if (tl<=l and r<=tr) return t[v];
ll m = (l + r)/2;
return ans(v*2, l, m, tl, tr) ^ ans(v*2+1, m+1, r, tl, tr);
}
ll ans1(ll v, ll l, ll r, ll tl, ll tr)
{
if (l>tr or r<tl) return 0;
if (tl<=l and r<=tr) return t1[v];
ll m = (l + r)/2;
return ans1(v*2, l, m, tl, tr) ^ ans1(v*2+1, m+1, r, tl, tr);
}
int main()
{
ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
ll n, q, k, x;
cin>>n>>q;
for (ll i = 1; i<=n; i++){
cin>>x;
if (i%2==0) b[i] = x;
else a[i] = x;
}
build(1, 1, n);
while (q--){
cin>>k;
if (k == 1){
ll i, j;
cin>>i>>j;
if (i%2==0){
update1(1, 1, n, i, j);
}
else {
update(1, 1, n, i, j);
}
}
else {
ll l, r;
cin>>l>>r;
if ((r-l+1)%2==0){
cout<<0<<endl;
}
else{
if (l%2==0){
cout<<ans1(1, 1, n, l, r)<<endl;
}
else {
cout<<ans(1, 1, n, l, r)<<endl;
}
}
}
}
}
# |
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 |
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 |
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 |
4444 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 |
1 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 |
2 ms |
4700 KB |
Output is correct |
12 |
Correct |
2 ms |
4696 KB |
Output is correct |
13 |
Correct |
2 ms |
4700 KB |
Output is correct |
14 |
Correct |
2 ms |
4700 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
87 ms |
7764 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
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 |
4444 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 |
1 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 |
2 ms |
4700 KB |
Output is correct |
12 |
Correct |
2 ms |
4696 KB |
Output is correct |
13 |
Correct |
2 ms |
4700 KB |
Output is correct |
14 |
Correct |
2 ms |
4700 KB |
Output is correct |
15 |
Incorrect |
87 ms |
7764 KB |
Output isn't correct |
16 |
Halted |
0 ms |
0 KB |
- |