답안 #466146

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
466146 2021-08-18T06:38:15 Z Stickfish XORanges (eJOI19_xoranges) C++17
100 / 100
633 ms 7112 KB
#include <iostream>
#include <vector>
using namespace std;

struct stree{
	void resize(int n){
		sz = 1;
		while(sz < n)sz <<= 1;
		t.assign(sz * 2 - 1, 0);
	}

	void xori(int i, int x){
		i += sz - 1;
		while(true){
			t[i] ^= x;
			i = (i - 1) / 2;
			if(i == 0)
				return;
		}
	}

	int get(int l, int r){
		l += sz - 1;
		r += sz - 2;
		int ans = 0;
		while(l <= r){
			if(l % 2 == 0)
				ans ^= t[l];
			l = l / 2;
			if(r % 2)
				ans ^= t[r];
			r = r / 2 - 1;
		}
		return ans;
	}
private:
	int sz;
	vector<int> t;
};

const int MAXN = 2e5 + 123;
int a[MAXN];

signed main(){
	int n, q;
	cin >> n >> q;
	stree sodd;
	stree seven;
	sodd.resize(n);
	seven.resize(n);
	for(int i = 0; i < n; ++i){
		cin >> a[i];
		if(i % 2){
			sodd.xori(i, a[i]);
		} else {
			seven.xori(i, a[i]);
		}
	}
	while(q--){
		int t;
		cin >> t;
		if(t == 1){
			int i, x;
			cin >> i >> x;
			--i;
			if(i % 2)
				sodd.xori(i, a[i] ^ x);
			else
				seven.xori(i, a[i] ^ x);
			a[i] = x;
		} else {
			int l, r;
			cin >> l >> r;
			--l;
			if((r - l) % 2 == 0){
				cout << 0 << '\n';
				continue;
			}
			int ans = 0;
			if(l % 2)
				ans = sodd.get(l, r);
			else
				ans = seven.get(l, r);
			cout << ans << '\n';
		}
	}
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 204 KB Output is correct
2 Correct 2 ms 204 KB Output is correct
3 Correct 2 ms 204 KB Output is correct
4 Correct 2 ms 204 KB Output is correct
5 Correct 2 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 256 KB Output is correct
6 Correct 2 ms 204 KB Output is correct
7 Correct 2 ms 204 KB Output is correct
8 Correct 2 ms 204 KB Output is correct
9 Correct 2 ms 204 KB Output is correct
10 Correct 2 ms 204 KB Output is correct
11 Correct 11 ms 460 KB Output is correct
12 Correct 12 ms 460 KB Output is correct
13 Correct 15 ms 460 KB Output is correct
14 Correct 14 ms 460 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 622 ms 6572 KB Output is correct
2 Correct 630 ms 6968 KB Output is correct
3 Correct 633 ms 6956 KB Output is correct
4 Correct 594 ms 7112 KB Output is correct
5 Correct 598 ms 6964 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 256 KB Output is correct
6 Correct 2 ms 204 KB Output is correct
7 Correct 2 ms 204 KB Output is correct
8 Correct 2 ms 204 KB Output is correct
9 Correct 2 ms 204 KB Output is correct
10 Correct 2 ms 204 KB Output is correct
11 Correct 11 ms 460 KB Output is correct
12 Correct 12 ms 460 KB Output is correct
13 Correct 15 ms 460 KB Output is correct
14 Correct 14 ms 460 KB Output is correct
15 Correct 622 ms 6572 KB Output is correct
16 Correct 630 ms 6968 KB Output is correct
17 Correct 633 ms 6956 KB Output is correct
18 Correct 594 ms 7112 KB Output is correct
19 Correct 598 ms 6964 KB Output is correct
20 Correct 465 ms 6400 KB Output is correct
21 Correct 503 ms 6416 KB Output is correct
22 Correct 475 ms 6464 KB Output is correct
23 Correct 581 ms 6908 KB Output is correct
24 Correct 593 ms 6980 KB Output is correct