Submission #444658

# Submission time Handle Problem Language Result Execution time Memory
444658 2021-07-14T14:15:35 Z drkarlicio2107 XORanges (eJOI19_xoranges) C++14
55 / 100
607 ms 3780 KB
#include <bits/stdc++.h>
using namespace std; int fen_parni [200010]; int fen_neparni [200010]; int l [200010];
void add_parni (int a, int v){
	for (a; a<200000; 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<200000; 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<200000; 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<200000; 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 2 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 2 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 12 ms 548 KB Output is correct
12 Correct 12 ms 460 KB Output is correct
13 Correct 19 ms 540 KB Output is correct
14 Correct 15 ms 536 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 607 ms 3780 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 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 2 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 12 ms 548 KB Output is correct
12 Correct 12 ms 460 KB Output is correct
13 Correct 19 ms 540 KB Output is correct
14 Correct 15 ms 536 KB Output is correct
15 Incorrect 607 ms 3780 KB Output isn't correct
16 Halted 0 ms 0 KB -