답안 #1098083

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1098083 2024-10-09T03:36:59 Z Alihan_8 XORanges (eJOI19_xoranges) C++17
100 / 100
71 ms 8772 KB
#include <bits/stdc++.h>

using namespace std;

struct fenwick{	
	vector <int> fenw;
	
	int n;
	
	fenwick(int n) : fenw(n + 1, 0), n(n) {}
	
	void upd(int i, int v){
		for (; i <= n; i += i & -i ) fenw[i] ^= v;
	} 
	
	int get(int i){
		int cnt = 0;
		
		for (; i > 0; i -= i & -i ) cnt ^= fenw[i];
		
		return cnt;
	}
	
	int qry(int l, int r){
		if ( (r - l) & 1 ) return 0;
		
		return get(r) ^ get(l - 1);
	}
};

signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	
	int n, q; cin >> n >> q;
	
	vector <int> a(n + 1);
	
	vector <fenwick> fn(2, fenwick(n + 1));
	
	for ( int i = 1; i <= n; i++ ){
		int x; cin >> x;
		
		a[i] = x;
		fn[i & 1].upd(i, x);
	}
	
	while ( q-- ){
		int t, l, u; cin >> t >> l >> u;
		
		if ( t == 1 ){
			fn[l & 1].upd(l, u);
			fn[l & 1].upd(l, a[l]);
			a[l] = u;
		} else cout << fn[l & 1].qry(l, u) << '\n';
	}
	
	cout << '\n';
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 2 ms 604 KB Output is correct
12 Correct 2 ms 604 KB Output is correct
13 Correct 2 ms 600 KB Output is correct
14 Correct 2 ms 604 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 60 ms 3892 KB Output is correct
2 Correct 62 ms 8772 KB Output is correct
3 Correct 60 ms 8768 KB Output is correct
4 Correct 61 ms 8492 KB Output is correct
5 Correct 71 ms 8320 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 2 ms 604 KB Output is correct
12 Correct 2 ms 604 KB Output is correct
13 Correct 2 ms 600 KB Output is correct
14 Correct 2 ms 604 KB Output is correct
15 Correct 60 ms 3892 KB Output is correct
16 Correct 62 ms 8772 KB Output is correct
17 Correct 60 ms 8768 KB Output is correct
18 Correct 61 ms 8492 KB Output is correct
19 Correct 71 ms 8320 KB Output is correct
20 Correct 66 ms 8516 KB Output is correct
21 Correct 62 ms 8512 KB Output is correct
22 Correct 62 ms 8512 KB Output is correct
23 Correct 57 ms 8260 KB Output is correct
24 Correct 64 ms 8256 KB Output is correct