답안 #763398

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
763398 2023-06-22T09:17:08 Z Halym2007 XORanges (eJOI19_xoranges) C++11
100 / 100
99 ms 11244 KB
#include <bits/stdc++.h>
#define ff first
#define ss second
#define sz size()
#define pb push_back
using namespace std;
typedef long long ll;
const int N = 600005;
// const int mod = 1e9+7;
// ll bigmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
void solve();
int n, q;
ll a[200005], sum, st[N][2];
 
 
void build (int ind, int x, int y) {
	if (x == y) {
		if (x % 2 == 1) {
			st[ind][1] = a[x]; 
		}
		else {
			st[ind][0] = a[x];
		}
		return;
	}
	build (ind * 2, x, (x + y) / 2);
	build (ind * 2 + 1, (x + y) / 2 + 1, y);
	st[ind][0] = st[ind * 2][0] ^ st[ind * 2 + 1][0];
	st[ind][1] = st[ind * 2][1] ^ st[ind * 2 + 1][1];
}	
 
 
 
void update (int ind, int l, int r, int x, int y, int op) {
	if (l == r and l == x) {
		st[ind][op] = y;
		return;
	}
	if(x < l or r < x) return;
	update(ind * 2, l, (l + r) / 2, x, y, op);
	update(ind * 2 + 1, (l + r) / 2 + 1, r, x, y, op);
	st[ind][op] = st[ind * 2][op] ^ st[ind * 2 + 1][op];
}
 
 
void jogap (int ind, int l, int r, int x, int y, int op) {
	if (r < x or y < l) return;
	if (x <= l and r <= y) {
		sum ^= st[ind][op];
		return;
	}
	jogap (ind * 2, l, (l + r) / 2, x, y, op);
	jogap (ind * 2 + 1, (l + r) / 2 + 1, r, x, y, op);
}
 
 
int main() {
	ios::sync_with_stdio(false);
 	cin.tie(0), cout.tie(0);
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    //  clock_t tStart = clock();
    // printf("Time taken: %.2fs\n", (double)(clock() - tStart)/CLOCKS_PER_SEC);
	cin >> n >> q;
	for (int i = 1; i <= n; ++i) {
		cin >> a[i];
	}
	build (1, 1, n);
	while ( q-- ) {
		int x, l, r;
		cin >> x >> l >> r;
		if (x == 2)
			if ((l % 2) != (r % 2)) {
				cout << "0\n";
				continue;
			}
		// if (n <= 0 and q <= 0) {
		// 	if (x == 1) {
		// 		a[l] = r;
		// 		continue;
		// 	}
		// 	sum = 0;
		// 	for (int i = l; i <= r; i += 2) {
		// 		sum ^= a[i];		
		// 	}
		// 	cout << sum << "\n";
		// 	continue;
		// }
		if (x == 1) {
			a[l] = r;
			update (1, 1, n, l, r, l % 2);
		}
		else {
			sum = 0;
			jogap (1, 1, n, l, r, l % 2);
			cout << sum << "\n";
		}
	}
}
/*
██╗░░██╗░█████╗░██╗░░░░░██╗░░░██╗███╗░░░███╗██████╗░░█████╗░░█████╗░███████╗
██║░░██║██╔══██╗██║░░░░░╚██╗░██╔╝████╗░████║╚════██╗██╔══██╗██╔══██╗╚════██║
███████║███████║██║░░░░░░╚████╔╝░██╔████╔██║░░███╔═╝██║░░██║██║░░██║░░░░██╔╝
██╔══██║██╔══██║██║░░░░░░░╚██╔╝░░██║╚██╔╝██║██╔══╝░░██║░░██║██║░░██║░░░██╔╝░
██║░░██║██║░░██║███████╗░░░██║░░░██║░╚═╝░██║███████╗╚█████╔╝╚█████╔╝░░██╔╝░░
╚═╝░░╚═╝╚═╝░░╚═╝╚══════╝░░░╚═╝░░░╚═╝░░░░░╚═╝╚══════╝░╚════╝░░╚════╝░░░╚═╝░░░
*/
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 2 ms 596 KB Output is correct
12 Correct 2 ms 596 KB Output is correct
13 Correct 2 ms 596 KB Output is correct
14 Correct 2 ms 596 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 91 ms 11244 KB Output is correct
2 Correct 91 ms 11212 KB Output is correct
3 Correct 93 ms 11168 KB Output is correct
4 Correct 83 ms 11212 KB Output is correct
5 Correct 82 ms 11224 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 2 ms 596 KB Output is correct
12 Correct 2 ms 596 KB Output is correct
13 Correct 2 ms 596 KB Output is correct
14 Correct 2 ms 596 KB Output is correct
15 Correct 91 ms 11244 KB Output is correct
16 Correct 91 ms 11212 KB Output is correct
17 Correct 93 ms 11168 KB Output is correct
18 Correct 83 ms 11212 KB Output is correct
19 Correct 82 ms 11224 KB Output is correct
20 Correct 97 ms 10572 KB Output is correct
21 Correct 99 ms 10564 KB Output is correct
22 Correct 97 ms 10680 KB Output is correct
23 Correct 86 ms 11196 KB Output is correct
24 Correct 86 ms 11232 KB Output is correct