Submission #441614

# Submission time Handle Problem Language Result Execution time Memory
441614 2021-07-05T14:46:52 Z nots0fast XORanges (eJOI19_xoranges) C++17
100 / 100
123 ms 8668 KB
#include <bits/stdc++.h>
using namespace std;
#define mp(a,b) make_pair(a,b)
#define ff first
#define setp setprecision
#define ss second
#define fori(v) for(ll i=0; i<v; i++)
#define forj(v) for(ll j=0; j<v; j++)
#define fork(v) for(ll k=0; k<v; k++)
#define forl(v) for(ll l=0; l<v; l++)
#define fort(v) for(ll t=0; t<v; t++)
#define forz(v) for(ll z=0; z<v; z++)
#define forx(v) for(ll x=0; x<v; x++)
#define fory(v) for(ll y=0; y<v; y++)
#define ll long long
#define ld long double
#define pb(a) push_back(a)
#define mt make_tuple
#define MAX (int)(2*pow(10,5) + 5)
// #define cout out
// #define cin in
ll inf = pow(10, 18);
ll INF = pow(10, 9);
ll modulo = 998244353;
double eps = 1e-10;

// start time 18 : 23

void updTillStart(ll id, ll val, vector<ll>& fen){
	ll sz = fen.size();
	id = min(id, sz-1);
	while(id){
		fen[id] ^= val;
		id -= id&-id;
	}
}

ll queTillEnd(ll id, vector<ll>& fen){
	ll s = 0;
	ll sz = fen.size();
	while(id < sz){
		s^=fen[id];
		id+=id&-id;
	}
	return s;
}

void deal(){
	ll n, q;
	cin>>n>>q;
	vector<vector<ll> > oddeven(2, vector<ll>(MAX, 0));
	for(ll i = 1; i<=n; i++){
		ll ed;
		cin>>ed;
		updTillStart(i, ed, oddeven[i%2]); 
	}
	forl(q){
		ll ty;
		cin>>ty;
		if(ty == 1){
			ll id, ed;
			cin>>id>>ed;
			ll val = queTillEnd(id, oddeven[id%2]) ^ queTillEnd(id+1, oddeven[id%2]);
			updTillStart(id, (val^ed), oddeven[id%2]);
		}
		else{
			ll l, r;
			cin>>l>>r;
			if((r-l)%2 == 1){
				cout<<0<<'\n';
			}
			else{
				cout<<(queTillEnd(l, oddeven[l%2]) ^ queTillEnd(r+1, oddeven[l%2]))<<'\n';
			}
		}
	}
}


int main(){
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	deal();  
}
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4940 KB Output is correct
2 Correct 3 ms 4920 KB Output is correct
3 Correct 3 ms 4940 KB Output is correct
4 Correct 3 ms 4940 KB Output is correct
5 Correct 3 ms 4912 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4940 KB Output is correct
2 Correct 3 ms 4940 KB Output is correct
3 Correct 3 ms 4940 KB Output is correct
4 Correct 3 ms 4940 KB Output is correct
5 Correct 3 ms 4940 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4940 KB Output is correct
2 Correct 3 ms 4920 KB Output is correct
3 Correct 3 ms 4940 KB Output is correct
4 Correct 3 ms 4940 KB Output is correct
5 Correct 3 ms 4912 KB Output is correct
6 Correct 3 ms 4940 KB Output is correct
7 Correct 3 ms 4940 KB Output is correct
8 Correct 3 ms 4940 KB Output is correct
9 Correct 3 ms 4940 KB Output is correct
10 Correct 3 ms 4940 KB Output is correct
11 Correct 5 ms 5068 KB Output is correct
12 Correct 6 ms 5068 KB Output is correct
13 Correct 6 ms 5068 KB Output is correct
14 Correct 6 ms 5068 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 121 ms 8668 KB Output is correct
2 Correct 117 ms 6436 KB Output is correct
3 Correct 117 ms 6496 KB Output is correct
4 Correct 113 ms 6436 KB Output is correct
5 Correct 113 ms 6424 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4940 KB Output is correct
2 Correct 3 ms 4920 KB Output is correct
3 Correct 3 ms 4940 KB Output is correct
4 Correct 3 ms 4940 KB Output is correct
5 Correct 3 ms 4912 KB Output is correct
6 Correct 3 ms 4940 KB Output is correct
7 Correct 3 ms 4940 KB Output is correct
8 Correct 3 ms 4940 KB Output is correct
9 Correct 3 ms 4940 KB Output is correct
10 Correct 3 ms 4940 KB Output is correct
11 Correct 5 ms 5068 KB Output is correct
12 Correct 6 ms 5068 KB Output is correct
13 Correct 6 ms 5068 KB Output is correct
14 Correct 6 ms 5068 KB Output is correct
15 Correct 121 ms 8668 KB Output is correct
16 Correct 117 ms 6436 KB Output is correct
17 Correct 117 ms 6496 KB Output is correct
18 Correct 113 ms 6436 KB Output is correct
19 Correct 113 ms 6424 KB Output is correct
20 Correct 116 ms 5908 KB Output is correct
21 Correct 121 ms 5880 KB Output is correct
22 Correct 118 ms 5864 KB Output is correct
23 Correct 113 ms 6432 KB Output is correct
24 Correct 123 ms 6436 KB Output is correct