Submission #976837

# Submission time Handle Problem Language Result Execution time Memory
976837 2024-05-07T07:29:02 Z Isam XORanges (eJOI19_xoranges) C++17
0 / 100
82 ms 7760 KB
#include<bits/stdc++.h>
using namespace std;

constexpr int sz = 2e5 + 5;

int n, q, a[sz], tree[2][sz];

inline void update(int pos, int val, int bj){
	
	while(pos <= n){
		
		tree[bj][pos] ^= val;
		
		pos += (pos & (-pos));
		
	}
	
	return;
}

inline int get_ans(int l, int r, int bj){
	if(l ^ 1) return get_ans(1, r, bj) ^ get_ans(1, l - 1, bj); 
	
	int res(0);
	
	while(r > 0){
		
		res ^= tree[bj][r];
		
		r -= (r & (-r));
		
		
	}
	
	return res;
	
}


signed main(){
	ios_base::sync_with_stdio(0), cin.tie(0);
	cin >> n >> q;
	for(register int i = 1; i <= n; ++i){
		cin >> a[i];
		update(i, a[i], i & 1);
	}	
	
	int type, l, r;
		
	while(q--){
		cin >> type >> l >> r;
		if(type == 1){
			
			update(l, a[l], l & 1);
			a[l] = r;
			update(l, a[l], l & 1);
			
		}else{
			if((l & 1) ^ (r & 1)){
				cout << get_ans(l, r, 1) << '\n';
			}else{
				cout << get_ans(l, r, 0) << '\n';
			}
			
			
		}
		
	}
	
	
	
	
}

Compilation message

xoranges.cpp: In function 'int main()':
xoranges.cpp:43:19: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   43 |  for(register int i = 1; i <= n; ++i){
      |                   ^
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 2508 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 2396 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 2508 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 82 ms 7760 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 2508 KB Output isn't correct
2 Halted 0 ms 0 KB -