Submission #444649

# Submission time Handle Problem Language Result Execution time Memory
444649 2021-07-14T14:05:04 Z drkarlicio2107 XORanges (eJOI19_xoranges) C++14
0 / 100
636 ms 8684 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 && (l-1)%2==1) cout << query_parni (r)-query_neparni (l-1) << endl;
				else if (r%2==0 && (l-1)%2==0) cout << query_parni (r)-query_parni (l-1) << endl; 
				else if (r%2==1 && (l-1)%2==1) cout << query_neparni (r)-query_neparni (l-1) << endl; 
				else if (r%2==1 && (l-1)%2==0) cout << query_neparni (r)-query_parni (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 Incorrect 1 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 636 ms 8684 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -