#include <bits/stdc++.h>
using namespace std;
long long tree[4*500000];
vector<int> vec;
void build(int node,int l,int r)
{
if(l==r)
{
tree[node]=vec[l];
}
else
{
int m=(l+r)/2;
build(node*2+1,l,m);
build(node*2+2,m+1,r);
tree[node]=min(tree[node*2+1],tree[node*2+2]);
}
}
void upd(int node,int pos,int x,int l,int r)
{
if(l==r)
{
tree[node]+=x;
return;
}
else
{
int m=(l+r)/2;
if(pos<=m)
{
upd(node*2+1,pos,x,l,m);
}
else
{
upd(node*2+2,pos,x,m+1,r);
}
tree[node]=tree[node*2+1]+tree[node*2+2];
}
}
long long sum(int node,int l, int r,int L,int R)
{
if(l>R || r<L)
{
return 0;
}
else if(l>=L && r<=R)
{
return tree[node];
}
else
{
int m=(l+r)/2;
return sum(node*2+1,l,m,L,R)+sum(node*2+2,m+1,r,L,R);
}
}
int main()
{
int n,q;
cin>>n>>q;
vector<int> vec;
for(;n>0;n--)
{
int x;
cin>>x;
vec.push_back(x);
}
for(;q>0;q--)
{
int x;
cin>>x;
if(x==1)
{
int a,b;
cin>>a>>b;
vec[a-1]=b;
}
else
{
int a,b;
cin>>a>>b;
if((b-a+1)%2==0)
{
cout<<0<<endl;
}
else
{
int res=-1;
int br=0;
for(int i=a-1;i<b;i=i+2)
{
if(res==-1)
res=vec[i];
else
{
res=res^vec[i];
}
}
cout<<res<<endl;
}
}
}
return 0;
}
Compilation message
xoranges.cpp: In function 'int main()':
xoranges.cpp:94:21: warning: unused variable 'br' [-Wunused-variable]
94 | int br=0;
| ^~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
344 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
448 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
344 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
448 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
9 ms |
632 KB |
Output is correct |
12 |
Correct |
7 ms |
624 KB |
Output is correct |
13 |
Correct |
12 ms |
600 KB |
Output is correct |
14 |
Correct |
14 ms |
604 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1065 ms |
4960 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
344 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
448 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
9 ms |
632 KB |
Output is correct |
12 |
Correct |
7 ms |
624 KB |
Output is correct |
13 |
Correct |
12 ms |
600 KB |
Output is correct |
14 |
Correct |
14 ms |
604 KB |
Output is correct |
15 |
Execution timed out |
1065 ms |
4960 KB |
Time limit exceeded |
16 |
Halted |
0 ms |
0 KB |
- |