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>
using namespace std;
#define pb push_back
#define ff first
#define ss second
#define endl "\n"
#define mod 1000000007
#define int long long
#define double long double
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
struct Fenwick{
int n;
vector<int> fw;
Fenwick(int _n){
fw.assign(n = _n+1,0);
}
void upd(int pos,int val){
while(pos <= n){
fw[pos] ^= val;
pos += (pos & -pos);
}
}
int get(int pos){
int res = 0;
while(pos > 0){
res ^= fw[pos];
pos -= (pos & -pos);
}
return res;
}
};
void solve(){
int n,q;
cin >> n >> q;
Fenwick odd(n),even(n);
vector<int> v(n+1);
for(int i=1;i<=n;i++){
cin >> v[i];
if(i % 2) odd.upd(i,v[i]);
else even.upd(i,v[i]);
}
for(int i=0;i<q;i++){
int ty,a,b;
cin >> ty >> a >> b;
if(ty == 1){
if(a % 2) odd.upd(a,v[a]),odd.upd(a,b);
else even.upd(a,v[a]),even.upd(a,b);
v[a] = b;
}
else{
if((b-a+1) % 2){
if(a % 2) cout << (odd.get(b) ^ odd.get(a-2)) << endl;
else cout << (even.get(b) ^ even.get(a-2)) << endl;
}
else cout << 0 << endl;
}
}
}
signed main(){
ios::sync_with_stdio(0);
cin.tie(0);
int t = 1;
//cin >> t;
while(t--)
solve();
return 0;
}
# | 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... |