# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
577141 |
2022-06-14T07:41:45 Z |
berr |
XORanges (eJOI19_xoranges) |
C++17 |
|
185 ms |
7188 KB |
#include <bits/stdc++.h>
using namespace std;
int st1[400005], st2[400005], t1[200005], t2[200005];
void build1(int l, int r, int v)
{
if(l>r) return;
else if(l==r) st1[v]=t1[l];
else
{
int mid=(l+r)/2;
build1(l, mid, v*2);
build1(mid+1, r, v*2+1);
st1[v]=(st1[v*2] xor st1[v*2+1]);
}
}
void build2(int l, int r, int v)
{
if(l>r) return;
else if(l==r) st2[v]=t2[l];
else
{
int mid=(l+r)/2;
build2(l, mid, v*2);
build2(mid+1, r, v*2+1);
st2[v]=(st2[v*2] xor st2[v*2+1]);
}
}
void update1(int l, int r, int v, int pos, int val)
{
if(l>r) return;
else if(l==r) t1[l]=st1[v]=val;
else
{
if((l+r)/2>=pos) update1(l, (l+r)/2, v*2, pos, val);
else update1((l+r)/2+1, r, v*2+1, pos, val);
st1[v]=(st1[v*2] xor st1[v*2+1]);
}
}
void update2(int l, int r, int v, int pos, int val)
{
if(l>r) return;
else if(l==r) t2[l]=st2[v]=val;
else
{
if((l+r)/2>=pos) update2(l, (l+r)/2, v*2, pos, val);
else update2((l+r)/2+1, r, v*2+1, pos, val);
st2[v]=st2[v*2] xor st2[v*2+1];
}
}
int get1(int l, int r, int tl, int tr, int v)
{
if(l>tr||r<tl){ return 0;}
if(tl<=l&&tr>=r){return st1[v];}
return (get1(l, (l+r)/2, tl, tr, v*2) xor (get1((l+r)/2+1, r, tl, tr, v*2+1)));
}
int get2(int l, int r, int tl, int tr, int v)
{
if(l>tr||r<tl) return 0;
if(tl<=l&&r<=tr) return st2[v];
return (get2(l, (l+r)/2, tl, tr, v*2) xor (get2((l+r)/2+1, r, tl, tr, v*2+1)));
}
int main()
{
ios_base::sync_with_stdio(false); cin.tie(0);
int n, q; cin>>n>>q;
int l=0, r=0;
for(int i=0; i<n; i++)
{
if(i%2==0) cin>>t1[l], l++;
else cin>>t2[r], r++;
}
build1(0, l-1, 1);
build2(0, r-1, 1);
while(q--)
{
int x, y, z; cin>>x>>y>>z;
y--;
if(x==1)
{
if(y%2==0) update1(0, l-1, 1, y/2, z);
else{update2(0, r-1, 1, y/2, z);}
}
else
{
z--;
if((z-y+1)%2==1)
{
if(y%2==0)
{
cout<<get1(0, l-1, y/2, z/2, 1);
}
else
{
cout<<get2(0, r-1, y/2, z/2, 1);
}
}
else
{
if((y+1)%2==1)
{
cout<<get1(0, l-1, (y+1)/2, (z/2), 1);
}
else
{
cout<<get2(0, l-1, (y+1)/2, (z/2), 1);
}
}
cout<<"\n";
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
336 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
185 ms |
7188 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |