Submission #739929

# Submission time Handle Problem Language Result Execution time Memory
739929 2023-05-11T16:36:11 Z pera XORanges (eJOI19_xoranges) C++14
100 / 100
630 ms 51848 KB
#include<bits/stdc++.h>

using namespace std;

#define pb push_back
#define ll long long
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

#define int ll

const ll mod = 1e9 + 7 , N = 2e5 + 1;

int n , q;
vector<int> a(N);
vector<vector<int>> t(4 * N , vector<int>(2));

int comb(int u , int v){
	return u ^ v;
}

void up(int v , int l , int r , int p , int val , int c){
	if(l == r){
		t[v][c] = val;
	}else{
		int m = (l + r) / 2;
		if(p <= m) up(v * 2 , l , m , p , val , c);
		else up(v * 2 + 1 , m + 1,  r , p , val , c);
		t[v][c] = comb(t[v * 2][c] , t[v * 2 + 1][c]);
	}
}

int xr(int v , int l , int r , int L , int R , int c){
	if(l > r || l > R || r < L) return 0;
	if(l >= L && r <= R){
		return t[v][c];
	}
	int m = (l + r) / 2;
	return comb(xr(v * 2 , l , m , L , R , c) , xr(v * 2 + 1 , m + 1 , r , L , R , c)); 
}

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];
		up(1 , 1 , n , (i + 1) / 2 , a[i] , i & 1);
	}
//	cout << xr(1 , 1 , n , 2 , 2 , 0) << endl;
	while(q --){
		int T , x , y;cin >> T >> x >> y;
		if(T == 1){
			up(1 , 1 , n , (x + 1) / 2 , y , x & 1);
		}else{
			int lo = 0 , ro = 0 , le = 0 , re = 0;
			if(x & 1) lo = (x + 1) / 2;
			else lo = x / 2 + 1;
			if(y & 1) ro = (y + 1) / 2;
			else ro = y / 2;
			le = (x + 1) / 2 , re = y / 2;
			int X1 = xr(1 , 1 , n , lo , ro , 1) , X2 = xr(1 , 1 , n  , le , re , 0) , X = 0;
			if(x == y && x & 1) X2 = 0;
			if(x == y && !(x & 1)) X1 = 0;
			/*cout << X1 << " " << X2 << endl;
			cout << "---------------" << endl;
			cout << lo << " " << ro << endl;
			cout << le << " " << re << endl;
			cout << "---------------" << endl;*/
			cout << ((y - x + 1) & 1 ? x & 1 ? X1 : X2 : 0) << endl;
		}
	}
}

Compilation message

xoranges.cpp:42:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   42 | main(){
      | ^~~~
xoranges.cpp: In function 'int main()':
xoranges.cpp:62:79: warning: unused variable 'X' [-Wunused-variable]
   62 |    int X1 = xr(1 , 1 , n , lo , ro , 1) , X2 = xr(1 , 1 , n  , le , re , 0) , X = 0;
      |                                                                               ^
# Verdict Execution time Memory Grader output
1 Correct 48 ms 45648 KB Output is correct
2 Correct 45 ms 45712 KB Output is correct
3 Correct 44 ms 45696 KB Output is correct
4 Correct 44 ms 45672 KB Output is correct
5 Correct 45 ms 45640 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 47 ms 45652 KB Output is correct
2 Correct 50 ms 45756 KB Output is correct
3 Correct 49 ms 45756 KB Output is correct
4 Correct 44 ms 45640 KB Output is correct
5 Correct 45 ms 45724 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 48 ms 45648 KB Output is correct
2 Correct 45 ms 45712 KB Output is correct
3 Correct 44 ms 45696 KB Output is correct
4 Correct 44 ms 45672 KB Output is correct
5 Correct 45 ms 45640 KB Output is correct
6 Correct 47 ms 45652 KB Output is correct
7 Correct 50 ms 45756 KB Output is correct
8 Correct 49 ms 45756 KB Output is correct
9 Correct 44 ms 45640 KB Output is correct
10 Correct 45 ms 45724 KB Output is correct
11 Correct 55 ms 45860 KB Output is correct
12 Correct 53 ms 45860 KB Output is correct
13 Correct 55 ms 45824 KB Output is correct
14 Correct 67 ms 45808 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 600 ms 47016 KB Output is correct
2 Correct 630 ms 51676 KB Output is correct
3 Correct 613 ms 51848 KB Output is correct
4 Correct 484 ms 51624 KB Output is correct
5 Correct 484 ms 51364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 48 ms 45648 KB Output is correct
2 Correct 45 ms 45712 KB Output is correct
3 Correct 44 ms 45696 KB Output is correct
4 Correct 44 ms 45672 KB Output is correct
5 Correct 45 ms 45640 KB Output is correct
6 Correct 47 ms 45652 KB Output is correct
7 Correct 50 ms 45756 KB Output is correct
8 Correct 49 ms 45756 KB Output is correct
9 Correct 44 ms 45640 KB Output is correct
10 Correct 45 ms 45724 KB Output is correct
11 Correct 55 ms 45860 KB Output is correct
12 Correct 53 ms 45860 KB Output is correct
13 Correct 55 ms 45824 KB Output is correct
14 Correct 67 ms 45808 KB Output is correct
15 Correct 600 ms 47016 KB Output is correct
16 Correct 630 ms 51676 KB Output is correct
17 Correct 613 ms 51848 KB Output is correct
18 Correct 484 ms 51624 KB Output is correct
19 Correct 484 ms 51364 KB Output is correct
20 Correct 436 ms 51532 KB Output is correct
21 Correct 420 ms 51384 KB Output is correct
22 Correct 432 ms 51488 KB Output is correct
23 Correct 490 ms 51400 KB Output is correct
24 Correct 470 ms 51360 KB Output is correct