//Author RufatM
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<string> vs;
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define endl '\n'
#define pb push_back
#define pf push_front
#define eb emplace_back
#define ff first
#define ss second
#define all(x) begin(x),end(x)
#define rall(x) rbegin(x),rend(x)
#define mt19937_64 mt_rand(chrono::steady_clock::now().time_since_epoch().count())
#define ordered_set tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
const int MOD=998244353;
const int INF=1000000007;
const ll LINF=4e18;
const int MAXN=2e5+5;
int n,q,mx;
ll a[MAXN],bit[MAXN][2];
void fenw_update(int i,ll v){
int t = i&1;
for(;i<=mx;i+=i&-i){
bit[i][t] ^= v;
}
}
ll fenw_get(ll i){
if(i<=0){
return 0;
}
int t = i&1;
ll cnt = 0;
for(;i>0;i-=i&-i){
cnt^=bit[i][t];
}
return cnt;
}
signed main(){
fastio;
#ifndef ONLINE_JUDGE
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
#endif
int t=1;
//cin >> t;
while(t--){
cin >> n >> q;
mx = n;
for(int i=1;i<=n;i++){
cin >> a[i];
fenw_update(i,a[i]);
}
while(q--){
int type,x,y;
cin >> type >> x >> y;
if(type == 1){
fenw_update(x,(a[x]^y));
a[x] = y;
}
else{
int l = x,r = y;
if(((r-l+1)&1)==0){
cout << 0 << endl;
continue;
}
cout << (fenw_get(r)^(fenw_get(l-2))) << 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... |