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 <algorithm>
#include <vector>
#include <math.h>
#include <map>
#define int long long
#define ff first
#define ss second
#define pb push_back
#define pp pop_back
#define all(x) x.begin(),x.end()
#define pii pair<int,int>
#define r0 return 0
using namespace std;
const int N = 5 * 1e5 + 5, M = 501, MOD = 998244353;
string s;
int tr[N],a[N],n,m,k,l,q,x,r,tr2[N];
void update(int node, int l ,int r ,int ind , int val) {
if (ind > r or ind < l) return;
if (l == r) {
tr[node] = val;
return;
}
int mid = ( l + r )/ 2;
update (node * 2, l, mid ,ind , val);
update (node * 2 + 1 , mid + 1 , r ,ind , val);
tr[node] = tr[node * 2] xor tr[node * 2 + 1];
}
int getans (int node, int l ,int r ,int st ,int end) {
if (end < l or st > r) return 0;
if (st <= l and r <= end) return tr[node];
int mid = (l + r) / 2;
return getans(node * 2, l , mid , st, end) xor getans (node * 2 + 1 , mid + 1 , r ,st , end);
}
void update2(int node, int l ,int r ,int ind , int val) {
if (ind > r or ind < l) return;
if (l == r) {
tr2[node] = val;
return;
}
int mid = ( l + r )/ 2;
update2 (node * 2, l, mid ,ind , val);
update2 (node * 2 + 1 , mid + 1 , r ,ind , val);
tr2[node] = tr2[node * 2] xor tr2[node * 2 + 1];
}
int getans2 (int node, int l ,int r ,int st ,int end) {
if (end < l or st > r) return 0;
if (st <= l and r <= end) return tr2[node];
int mid = (l + r) / 2;
return getans2(node * 2, l , mid , st, end) xor getans2(node * 2 + 1 , mid + 1 , r ,st , end);
}
signed main(){
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
cin >> n >> q;
for (int i = 1; i <= n; i++) {
cin >> a[i];
if (i % 2 == 1) update(1,1,n,i,a[i]);
if (i % 2 == 0) update2(1,1,n,i,a[i]);
}
for (int i = 1; i <= n; i++) {
cin >> x >> l >> r;
if (x == 1){
if (l % 2 == 1) update(1,1,n,l,r);
if (l % 2 == 0) update2(1,1,n,l,r);
} else {
int check1 = r - l + 1;
if (check1 % 2 == 0) {
cout << 0 << endl;
// cout << "CHECK" << endl;
} else if (l % 2 == 0){
int ans = getans2(1,1,n,l,r);
cout << ans << endl;
} else if (l % 2 == 1) {
int ans = getans (1,1,n,l,r);
cout << ans << endl;
}
}
}
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... |