답안 #446792

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
446792 2021-07-23T09:20:07 Z fuad27 XORanges (eJOI19_xoranges) C++14
100 / 100
693 ms 3144 KB
#include<bits/stdc++.h>
using namespace std;
int fenwick[2000000][2] = {0}, v[2000010];
void upd(int i, int w, int r) {
	while(i <= 2000000) {
		fenwick[i][w] ^= r;
		i += i&(-i);
	}
}
int getXor(int i, int w) {
	int x = 0;
	while(i>0) {
		x^=fenwick[i][w];
		i -= i&(-i);
	}
	return x;
}
int32_t main () {
	int n, q;
	cin >> n >> q;
	for(int i = 1;i<=n;i++) {
		cin >> v[i];
		upd(ceil(i/2.0), i%2, v[i]);
	}
	for(int i = 1;i<=q;i++) {
		int k;
		cin >> k;
		if(k==1) {
			int j, val;
			cin >> j >> val;
			upd(ceil(j/2.0), j%2, (val ^ v[j]));		
			v[j] = val;
		}
		else {
			int l, u;
			cin >> l >> u;
			if((u - l + 1)%2 == 0)cout<<0<<endl;
			else {
				int a = l%2;
				l-=2;
				int ans = getXor(ceil(u/2.0), a) ^ getXor(ceil(l/2.0), a);cout<<ans<<endl;
			}
		}
	}
}
# 결과 실행 시간 메모리 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
# 결과 실행 시간 메모리 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 444 KB Output is correct
5 Correct 2 ms 332 KB Output is correct
# 결과 실행 시간 메모리 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 444 KB Output is correct
10 Correct 2 ms 332 KB Output is correct
11 Correct 12 ms 332 KB Output is correct
12 Correct 11 ms 416 KB Output is correct
13 Correct 15 ms 332 KB Output is correct
14 Correct 15 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 601 ms 3016 KB Output is correct
2 Correct 645 ms 3012 KB Output is correct
3 Correct 693 ms 3144 KB Output is correct
4 Correct 606 ms 2992 KB Output is correct
5 Correct 615 ms 3068 KB Output is correct
# 결과 실행 시간 메모리 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 444 KB Output is correct
10 Correct 2 ms 332 KB Output is correct
11 Correct 12 ms 332 KB Output is correct
12 Correct 11 ms 416 KB Output is correct
13 Correct 15 ms 332 KB Output is correct
14 Correct 15 ms 332 KB Output is correct
15 Correct 601 ms 3016 KB Output is correct
16 Correct 645 ms 3012 KB Output is correct
17 Correct 693 ms 3144 KB Output is correct
18 Correct 606 ms 2992 KB Output is correct
19 Correct 615 ms 3068 KB Output is correct
20 Correct 461 ms 2508 KB Output is correct
21 Correct 465 ms 2500 KB Output is correct
22 Correct 465 ms 2492 KB Output is correct
23 Correct 588 ms 2996 KB Output is correct
24 Correct 596 ms 2936 KB Output is correct