#include <bits/stdc++.h>
#define TASK "kajsdkajsdkasdj"
#define INT_LIM (int) 2147483647
#define LL_LIM (long long) 9223372036854775807
#define endl '\n'
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define BIT(i,x) (((i)>>(x))&1)
#define FOR(i,a,b) for(int i = (a); i<=(b); i++)
#define FORD(i,a,b) for(int i = (a); i>=(b); i--)
#define ll long long
#define pii pair<int,int>
using namespace std;
///------------------------------------------///
struct Fenwick{
int n;
ll f[200005];
void init(int _n)
{
n = _n;
FOR(i, 1, n) f[i] = 0;
}
void update(int p, ll delta)
{
for (int i = p; i<=n; i+=(i&(-i))) f[i]^=delta;
}
ll get(int l, int r)
{
ll ret = 0;
for (int i = r; i>0; i-=(i&(-i))) ret^=f[i];
for (int i = l-1; i>0; i-=(i&(-i))) ret^= f[i];
return ret;
}
} f0, f1;
int n,q;
ll a[200005];
void inp()
{
cin >> n >> q;
f0.init(n); f1.init(n);
FOR(i, 1, n) cin >> a[i];
}
void solve()
{
FOR(i, 1, n)
{
if (i&1) f1.update(i, a[i]);
else f0.update(i, a[i]);
}
FOR(i, 1, q)
{
int type;
cin >> type;
if (type==1)
{
int p; ll val;
cin >> p >> val;
ll delta = val^a[p];
a[p] = val;
if (p&1) f1.update(p, delta);
else f0.update(p, delta);
}
else
{
int l,r;
cin >> l >> r;
if ((r-l+1)&1)
{
if (l&1) cout << f1.get(l, r) << endl;
else cout << f0.get(l,r) << endl;
}
else cout << 0 << endl;
}
}
}
signed main()
{
///--------------------------///
ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
if (fopen(TASK".INP","r")!=NULL)
{
freopen(TASK".INP","r",stdin);
freopen(TASK".OUT","w",stdout);
}
///--------------------------///
int NTEST = 1;
//cin >> NTEST;
while (NTEST--)
{
inp();
solve();
}
return 0;
}
///------------------------------------------///
Compilation message (stderr)
xoranges.cpp: In function 'int main()':
xoranges.cpp:89:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
89 | freopen(TASK".INP","r",stdin);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
xoranges.cpp:90:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
90 | freopen(TASK".OUT","w",stdout);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
# | 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... |