Submission #1131649

#TimeUsernameProblemLanguageResultExecution timeMemory
1131649ByeWorldXORanges (eJOI19_xoranges)C++20
100 / 100
280 ms3132 KiB
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#define ll long long
#define pb push_back
#define fi first
#define se second
#define lf (id<<1)
#define rg ((id<<1)|1)
#define md ((l+r)>>1)
#define ld long double
using namespace std;
typedef pair<int,int> pii;
typedef pair<char,char> pcc;
typedef pair<int,pii> ipii;
typedef pair<pii,pii> ipiii;
const int MAXN = 2e5+10;
const int MAXA = 1e6;
const int MOD = 1e9+7;
const int INF = 1e18+10;
const int LOG = 21;
const ld EPS = 1e-12;

int n,q;

struct seg {
	int st[2*MAXN];
	int que(int x){
		int te = 0;
		for(; x>=1; x-=(x&(-x))) te ^= st[x];
		return te;
	}
	void upd(int x, int p){
		for(; x<=2*MAXN-20; x+=(x&(-x)))
			st[x] ^= p;
	}
} O, E;
int a[MAXN];
int QUE(int l, int r){
	if(l%2){
		return O.que(r/2+1) ^ O.que(l/2);
	}
	return E.que(r/2) ^ E.que(l/2-1);
}
signed main(){
	cin >> n >> q;
	for(int i=1; i<=n; i++){
		cin >> a[i];
		if(i%2) O.upd(i/2+1, a[i]);
		else E.upd(i/2, a[i]);
	}
	while(q--){
		int ty, x,y; cin>>ty>>x>>y;
		if(ty==2){
			if((y-x+1) % 2 == 0) cout << "0\n";
			else cout << QUE(x, y) << '\n';
		} else {
			if(x%2){
				O.upd(x/2+1, a[x] ^ y);
			} else {
				E.upd(x/2, a[x] ^ y);
			}
			a[x] = y;
		}
	}
}

Compilation message (stderr)

xoranges.cpp:19:21: warning: overflow in conversion from 'double' to 'int' changes value from '1.0e+18' to '2147483647' [-Woverflow]
   19 | const int INF = 1e18+10;
      |                 ~~~~^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...