Submission #444660

# Submission time Handle Problem Language Result Execution time Memory
444660 2021-07-14T14:18:49 Z drkarlicio2107 XORanges (eJOI19_xoranges) C++14
100 / 100
672 ms 8644 KB
#include <bits/stdc++.h>
using namespace std; int fen_parni [200020]; int fen_neparni [200020]; int l [200020];
void add_parni (int a, int v){
	for (a; a<200010; a+= a & -a) fen_parni[a]^=v;
}
int query_parni (int a){
	int res=0;
	for (a; a>0; a-= a & -a) res^=fen_parni[a];
	return res;
}
void add_neparni (int a, int v){
	for (a; a<200010; a+= a & -a) fen_neparni[a]^=v;
}
int query_neparni (int a){
	int res=0;
	for (a; a>0; a-= a & -a) res^=fen_neparni[a];
	return res;
}
int main(){
	int n,q; cin >> n >> q;
	for (int i=1; i<n+1; i++){
		int a; cin >> a;
		if (i%2==0) add_parni (i, a);
		else add_neparni (i, a);
		l[i]=a;
		/*
		if (i%2==0) cout << query_parni (i) << endl;
		else cout << query_neparni (i) << endl;
		*/
	}
	for (int i=0; i<q; i++){
		int x; cin >> x;
		if (x==1){
			int a, b; cin >> a >> b;
			if (a%2==0){
				add_parni (a, l[a]); add_parni (a, b);
			}
			else {
				add_neparni (a, l[a]); add_neparni (a, b);
			}
			l[a]=b;
		}
		else {
			int l, r; cin >> l >> r;
			if ((r-l+1)%2==0) cout << 0 << endl;
			else {
				if (l==1){
					if (r%2==0) cout << query_parni (r) << endl;
					else cout << query_neparni (r) << endl;
				}
				else if (r%2==0) cout << (query_parni (r)^query_parni (l-1)) << endl;
				else if (r%2==1) cout << (query_neparni (r)^query_neparni (l-1)) << endl; 
			}
		}
	}
}

Compilation message

xoranges.cpp: In function 'void add_parni(int, int)':
xoranges.cpp:4:7: warning: statement has no effect [-Wunused-value]
    4 |  for (a; a<200010; a+= a & -a) fen_parni[a]^=v;
      |       ^
xoranges.cpp: In function 'int query_parni(int)':
xoranges.cpp:8:7: warning: statement has no effect [-Wunused-value]
    8 |  for (a; a>0; a-= a & -a) res^=fen_parni[a];
      |       ^
xoranges.cpp: In function 'void add_neparni(int, int)':
xoranges.cpp:12:7: warning: statement has no effect [-Wunused-value]
   12 |  for (a; a<200010; a+= a & -a) fen_neparni[a]^=v;
      |       ^
xoranges.cpp: In function 'int query_neparni(int)':
xoranges.cpp:16:7: warning: statement has no effect [-Wunused-value]
   16 |  for (a; a>0; a-= a & -a) res^=fen_neparni[a];
      |       ^
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 332 KB Output is correct
2 Correct 3 ms 332 KB Output is correct
3 Correct 2 ms 332 KB Output is correct
4 Correct 2 ms 332 KB Output is correct
5 Correct 2 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 2 ms 332 KB Output is correct
7 Correct 3 ms 332 KB Output is correct
8 Correct 2 ms 332 KB Output is correct
9 Correct 2 ms 332 KB Output is correct
10 Correct 2 ms 332 KB Output is correct
11 Correct 11 ms 332 KB Output is correct
12 Correct 12 ms 424 KB Output is correct
13 Correct 15 ms 332 KB Output is correct
14 Correct 16 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 661 ms 3796 KB Output is correct
2 Correct 672 ms 8624 KB Output is correct
3 Correct 611 ms 8644 KB Output is correct
4 Correct 587 ms 8260 KB Output is correct
5 Correct 618 ms 8260 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 2 ms 332 KB Output is correct
7 Correct 3 ms 332 KB Output is correct
8 Correct 2 ms 332 KB Output is correct
9 Correct 2 ms 332 KB Output is correct
10 Correct 2 ms 332 KB Output is correct
11 Correct 11 ms 332 KB Output is correct
12 Correct 12 ms 424 KB Output is correct
13 Correct 15 ms 332 KB Output is correct
14 Correct 16 ms 332 KB Output is correct
15 Correct 661 ms 3796 KB Output is correct
16 Correct 672 ms 8624 KB Output is correct
17 Correct 611 ms 8644 KB Output is correct
18 Correct 587 ms 8260 KB Output is correct
19 Correct 618 ms 8260 KB Output is correct
20 Correct 572 ms 8296 KB Output is correct
21 Correct 524 ms 8416 KB Output is correct
22 Correct 466 ms 8384 KB Output is correct
23 Correct 591 ms 8276 KB Output is correct
24 Correct 624 ms 8236 KB Output is correct