This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
/// author: LilPluton auuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu
using namespace std;
#define int long long
const int N = 3e5 + 5;
const int INF = 1e18;
const int md = 1e9 + 7;
void show(vector<int> &a)
{
for(auto i : a)
cout << i << ' ';
cout << endl;
}
int n, q;
struct tree
{
int st[N * 4];
tree()
{
memset(st, 0, sizeof(st));
}
void upd(int in,int l,int r,int pos,int val)
{
if(l == r)
{
st[in] = val;
return;
}
int mid = (l + r) >> 1;
if(pos <= mid) upd(in * 2, l, mid, pos, val);
else upd(in * 2 + 1, mid + 1, r, pos, val);
st[in] = st[in * 2] ^ st[in * 2 + 1];
}
int getans(int in,int tl,int tr,int l,int r)
{
if(tr < l || tl > r) return 0;
if(l <= tl && tr <= r) return st[in];
int mid = (tl + tr) / 2;
return getans(in * 2, tl, mid, l, r) ^ getans(in * 2 + 1, mid + 1, tr, l, r);
}
} seg1, seg2;
signed main()
{
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
cin >> n >> q;
for(int i = 1, x; i <= n; ++i)
{
cin >> x;
if(i & 1) seg1.upd(1,1,n,i / 2 + 1, x);
else seg2.upd(1,1,n,i/2,x);
}
while(q--)
{
int t,l,r;
cin >> t >> l >> r;
if(t == 1)
{
if(l & 1) seg1.upd(1,1,n,l / 2 + 1, r);
else seg2.upd(1,1,n,l / 2, r);
}
else
{
int id = (r - l + 1);
if(id & 1)
{
if(l & 1) cout << seg1.getans(1,1,n,l / 2 + 1, l / 2 + 1 + id / 2) << endl;
else cout << seg2.getans(1,1,n,l / 2, l / 2 + id / 2) << endl;
}
else
{
cout << 0 << endl;
}
}
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |