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 <iostream>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
using namespace std;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef long long ll;
#define loop(i,a,b) for (int i = a; i <= b; i++)
#define INF ((unsigned) ~0)
#define F first
#define S second
#define PB push_back
#define MP make_pair
const int MXN = 200000;
int n, q;
int st[2*MXN];
int gi(int i){
if(i % 2 == 0)
return i / 2;
return (n + i) / 2;
}
int rxq(int l, int r){
int res = 0;
for (l += n, r += n; l < r; l >>= 1, r >>= 1) {
if (l&1) res ^= st[l++];
if (r&1) res ^= st[--r];
}
return res;
}
int main(){
cin >> n >> q;
for(int i = 0; i < n; i++)
cin >> st[gi(i) + n];
for(int i = n - 1; i > 1; i--)
st[i] = st[i<<1] ^ st[i<<1|1];
while(q--){
int tp, a, b;
cin >> tp >> a >> b;
a--;
if(tp == 1){
a = gi(a) + n;
st[a] = b;
while(a >= 1){
a = a >> 1;
st[a] = st[a<<1] ^ st[a<<1|1];
}
}else{
b--;
if(a % 2 == b % 2){
cout << rxq(gi(a), gi(b) + 1) << "\n";
}else{
cout << "0\n";
}
}
}
}
# | 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... |