54302023-05-23 16:39:27111Xorzótáblacpp14Accepted 100/1001.934s34356 KiB
#include <bits/stdc++.h>
using namespace std;

#define BIT(x, i) ((x) >> (i) & 1)
#define LOPT(i) (~0 ^ ~0 << (i))
 
// az stl-re semmit se lehet bizni...

int cmp(const void* a, const void* b) {
    if (*(int*)a < *(int*)b) {
		return -1;
    }
    else if (*(int*)a > *(int*)b) {
		return 1;
    }
    else {
		return 0;
    }
}

int bs(const vector<int>& v, int x) {
	int l = 0, h = v.size();
	while (l != h) {
		int m = (l + h) / 2;
		if (v[m] >= x) {
			h = m;
		}
		else {
			l = m + 1;
		}
	}
	return h;
}

int main() {
	int AC, BC;
	cin >> AC >> BC;
	vector<int> A(AC), B(BC);
	for (int i = 0; i < AC; i++) {
		cin >> A[i];
	}
	for (int i = 0; i < BC; i++) {
		cin >> B[i];
	}
	vector<vector<int>> v(32);
	vector<vector<int>> w(32);
	int x = 0;
	for (int i = 0; i < 32; i++) {
		for (int j = 0; j < AC; j++) {
			if (BIT(A[j], i)) {
				v[i].push_back(A[j] & LOPT(i));
			}
			else {
				w[i].push_back(A[j] & LOPT(i));
			}
		}
		qsort(v[i].data(), v[i].size(), sizeof(int), cmp);
		qsort(w[i].data(), w[i].size(), sizeof(int), cmp);
	}
	for (int i = 0; i < BC; i++) {
		for (int j = 0; j < 32; j++) {
			int c = 0;
			int y = (1 << j) - (B[i] & LOPT(j));
			if (BIT(B[i], j)) {
				c += w[j].size();
				c += v[j].size() - bs(v[j], y);
				c -= w[j].size() - bs(w[j], y);
			}
			else {
				c += v[j].size();
				c += w[j].size() - bs(w[j], y);
				c -= v[j].size() - bs(v[j], y);
			}
			x ^= c % 2 << j;
		}
	}
	cout << x << endl;
	return 0;
}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted3ms1808 KiB
2Accepted1.597s26604 KiB
subtask214/14
3Accepted1.597s26604 KiB
4Accepted3ms2092 KiB
5Accepted4ms2116 KiB
6Accepted6ms2756 KiB
7Accepted4ms2548 KiB
8Accepted8ms3064 KiB
9Accepted9ms3048 KiB
10Accepted12ms3464 KiB
subtask314/14
11Accepted12ms3464 KiB
12Accepted3ms3268 KiB
13Accepted1.371s31760 KiB
14Accepted1.697s31548 KiB
15Accepted1.899s34356 KiB
16Accepted1.899s31836 KiB
subtask414/14
17Accepted1.899s31836 KiB
18Accepted372ms18240 KiB
19Accepted560ms30604 KiB
20Accepted634ms33096 KiB
21Accepted683ms33260 KiB
22Accepted697ms33248 KiB
subtask521/21
23Accepted697ms33248 KiB
24Accepted92ms9896 KiB
25Accepted352ms16528 KiB
26Accepted524ms31596 KiB
27Accepted589ms29248 KiB
28Accepted629ms31704 KiB
29Accepted340ms31860 KiB
subtask637/37
30Accepted340ms31860 KiB
31Accepted72ms7748 KiB
32Accepted1.088s11304 KiB
33Accepted1.22s32140 KiB
34Accepted1.411s22048 KiB
35Accepted1.902s33132 KiB
36Accepted1.934s32592 KiB
37Accepted370ms32160 KiB
38Accepted1.893s33316 KiB
39Accepted1.878s33388 KiB