150002025-02-10 21:58:48feheristvanXorzótáblacpp17Time limit exceeded 49/1002.101s17640 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
1Accepted1ms316 KiB
2Accepted1.682s14352 KiB
subtask214/14
3Accepted1ms316 KiB
4Accepted2ms316 KiB
5Accepted4ms564 KiB
6Accepted2ms316 KiB
7Accepted8ms564 KiB
8Accepted8ms316 KiB
9Accepted10ms564 KiB
subtask30/14
10Accepted1ms316 KiB
11Accepted1.503s15952 KiB
12Accepted1.947s16312 KiB
13Time limit exceeded2.101s17640 KiB
14Time limit exceeded2.039s16536 KiB
subtask414/14
15Accepted400ms8772 KiB
16Accepted630ms15356 KiB
17Accepted731ms16520 KiB
18Accepted769ms16828 KiB
19Accepted791ms16928 KiB
subtask521/21
20Accepted101ms3320 KiB
21Accepted382ms6692 KiB
22Accepted615ms14484 KiB
23Accepted666ms13380 KiB
24Accepted718ms14828 KiB
25Accepted351ms14896 KiB
subtask60/37
26Accepted79ms2100 KiB
27Accepted1.093s4916 KiB
28Accepted1.383s15708 KiB
29Accepted1.449s10440 KiB
30Time limit exceeded2.088s16468 KiB
31Time limit exceeded2.081s16428 KiB
32Accepted393ms16104 KiB
33Time limit exceeded2.059s16788 KiB
34Accepted1.953s16592 KiB