#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define sc second
#define th third
#define fo fourth
#define pii pair<int,int>
#define pll pair<ll,ll>
#define ldb double
#define endl "\n"
#define all(data) data.begin(),data.end()
#define TYPEMAX(type) std::numeric_limits<type>::max()
#define TYPEMIN(type) std::numeric_limits<type>::min()
#define MAXN 200007
void update(vector<ll>& v, ll k, ll x)
{
while(k<=v.size())
{
v[k]^=x;
k+=k&-k;
}
}
ll prefsum1(const vector<ll>& v, ll k)
{
ll sum=0;
while(k>0)
{
sum^=v[k];
k-=k&-k;
}
return sum;
}
int main()
{
ios::sync_with_stdio(false); cin.tie(0);
ll n,q; cin>>n>>q;
ll a[n+1]; a[0]=0;
vector<ll> BIT2(n+1,0),BIT3(n+1,0);
for(int i=1;i<=n;i++)
{
cin>>a[i];
if(i%2==0) update(BIT2, i, a[i]);
else update(BIT3, i, a[i]);
}
for(int i=1;i<=q;i++)
{
ll x,y,z; cin>>x>>y>>z;
if(x==2)
{
if((z-y+1)%2==0) cout<<0<<endl;
else
{
if(y%2==0) cout<<((prefsum1(BIT2, z))^(prefsum1(BIT2, y-1)))<<endl;
else cout<<((prefsum1(BIT3, z))^(prefsum1(BIT3, y-1)))<<endl;
}
}
else
{
if(y%2==0) update(BIT2, y, z^a[y]);
else update(BIT3, y, z^a[y]);
a[y]=z;
}
}
return 0;
}
Compilation message
xoranges.cpp: In function 'void update(std::vector<long long int>&, long long int, long long int)':
xoranges.cpp:23:12: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
23 | while(k<=v.size())
| ~^~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
320 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 |
324 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 |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
320 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 |
324 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 |
2 ms |
460 KB |
Output is correct |
12 |
Correct |
3 ms |
468 KB |
Output is correct |
13 |
Correct |
2 ms |
468 KB |
Output is correct |
14 |
Correct |
2 ms |
468 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
99 ms |
10988 KB |
Output is correct |
2 |
Correct |
116 ms |
11020 KB |
Output is correct |
3 |
Correct |
96 ms |
11004 KB |
Output is correct |
4 |
Correct |
92 ms |
10636 KB |
Output is correct |
5 |
Correct |
96 ms |
10636 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
320 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 |
324 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 |
2 ms |
460 KB |
Output is correct |
12 |
Correct |
3 ms |
468 KB |
Output is correct |
13 |
Correct |
2 ms |
468 KB |
Output is correct |
14 |
Correct |
2 ms |
468 KB |
Output is correct |
15 |
Correct |
99 ms |
10988 KB |
Output is correct |
16 |
Correct |
116 ms |
11020 KB |
Output is correct |
17 |
Correct |
96 ms |
11004 KB |
Output is correct |
18 |
Correct |
92 ms |
10636 KB |
Output is correct |
19 |
Correct |
96 ms |
10636 KB |
Output is correct |
20 |
Correct |
96 ms |
10764 KB |
Output is correct |
21 |
Correct |
92 ms |
10760 KB |
Output is correct |
22 |
Correct |
110 ms |
10808 KB |
Output is correct |
23 |
Correct |
88 ms |
10600 KB |
Output is correct |
24 |
Correct |
88 ms |
10700 KB |
Output is correct |