54292023-05-23 16:08:31111Xorzótáblacpp14Time limit exceeded 35/1002.076s66400 KiB
#include <bits/stdc++.h>
using namespace std;

#define int long long

#define BSEARCH(v, x) (distance((v).begin(), lower_bound((v).begin(), (v).end(), (x))))

#define BIT(x, i) ((x) >> (i) & 1ll)
#define LOPT(i) (~0ll ^ ~0ll << (i))

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(34);
	vector<vector<int>> w(34);
	int x = 0;
	for (int i = 0; i < 34; 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));
			}
		}
		sort(v[i].begin(), v[i].end());
		sort(w[i].begin(), w[i].end());
	}
	for (int i = 0; i < BC; i++) {
		for (int j = 0; j < 34; j++) {
			int c = 0;
			if (BIT(B[i], j)) {
				c += w[j].size();
				c += v[j].size() - BSEARCH(v[j], (1ll << j) - (B[i] & LOPT(j)));
				c -= w[j].size() - BSEARCH(w[j], (1ll << j) - (B[i] & LOPT(j)));
			}
			else {
				c += v[j].size();
				c += w[j].size() - BSEARCH(w[j], (1ll << j) - (B[i] & LOPT(j)));
				c -= v[j].size() - BSEARCH(v[j], (1ll << j) - (B[i] & LOPT(j)));
			}
			x ^= c % 2 << j;
		}
	}
	cout << x << endl;
	return 0;
}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted3ms1808 KiB
2Accepted1.695s55352 KiB
subtask214/14
3Accepted1.695s55352 KiB
4Accepted3ms2232 KiB
5Accepted4ms2344 KiB
6Accepted6ms3272 KiB
7Accepted4ms2920 KiB
8Accepted8ms3552 KiB
9Accepted8ms3532 KiB
10Accepted10ms3920 KiB
subtask30/14
11Accepted10ms3920 KiB
12Accepted3ms3296 KiB
13Accepted1.348s63260 KiB
14Accepted1.842s60224 KiB
15Time limit exceeded2.076s34000 KiB
16Time limit exceeded2.028s65188 KiB
subtask40/14
17Time limit exceeded2.028s65188 KiB
18Accepted287ms34860 KiB
19Accepted404ms58912 KiB
20Accepted462ms65364 KiB
21Accepted504ms64904 KiB
22Accepted523ms65284 KiB
subtask521/21
23Accepted523ms65284 KiB
24Accepted63ms16860 KiB
25Accepted291ms28740 KiB
26Accepted374ms63228 KiB
27Accepted449ms58964 KiB
28Accepted469ms63880 KiB
29Accepted282ms62500 KiB
subtask60/37
30Accepted282ms62500 KiB
31Accepted59ms10804 KiB
32Accepted1.126s18088 KiB
33Accepted1.177s66168 KiB
34Accepted1.503s40824 KiB
35Time limit exceeded2.072s35572 KiB
36Time limit exceeded2.068s35380 KiB
37Accepted300ms62848 KiB
38Time limit exceeded2.04s34896 KiB
39Accepted1.947s66400 KiB