5429 | 2023-05-23 16:08:31 | 111 | Xorzótábla | cpp14 | Time limit exceeded 35/100 | 2.076s | 66400 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;
}
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Accepted | 3ms | 1808 KiB | ||||
2 | Accepted | 1.695s | 55352 KiB | ||||
subtask2 | 14/14 | ||||||
3 | Accepted | 1.695s | 55352 KiB | ||||
4 | Accepted | 3ms | 2232 KiB | ||||
5 | Accepted | 4ms | 2344 KiB | ||||
6 | Accepted | 6ms | 3272 KiB | ||||
7 | Accepted | 4ms | 2920 KiB | ||||
8 | Accepted | 8ms | 3552 KiB | ||||
9 | Accepted | 8ms | 3532 KiB | ||||
10 | Accepted | 10ms | 3920 KiB | ||||
subtask3 | 0/14 | ||||||
11 | Accepted | 10ms | 3920 KiB | ||||
12 | Accepted | 3ms | 3296 KiB | ||||
13 | Accepted | 1.348s | 63260 KiB | ||||
14 | Accepted | 1.842s | 60224 KiB | ||||
15 | Time limit exceeded | 2.076s | 34000 KiB | ||||
16 | Time limit exceeded | 2.028s | 65188 KiB | ||||
subtask4 | 0/14 | ||||||
17 | Time limit exceeded | 2.028s | 65188 KiB | ||||
18 | Accepted | 287ms | 34860 KiB | ||||
19 | Accepted | 404ms | 58912 KiB | ||||
20 | Accepted | 462ms | 65364 KiB | ||||
21 | Accepted | 504ms | 64904 KiB | ||||
22 | Accepted | 523ms | 65284 KiB | ||||
subtask5 | 21/21 | ||||||
23 | Accepted | 523ms | 65284 KiB | ||||
24 | Accepted | 63ms | 16860 KiB | ||||
25 | Accepted | 291ms | 28740 KiB | ||||
26 | Accepted | 374ms | 63228 KiB | ||||
27 | Accepted | 449ms | 58964 KiB | ||||
28 | Accepted | 469ms | 63880 KiB | ||||
29 | Accepted | 282ms | 62500 KiB | ||||
subtask6 | 0/37 | ||||||
30 | Accepted | 282ms | 62500 KiB | ||||
31 | Accepted | 59ms | 10804 KiB | ||||
32 | Accepted | 1.126s | 18088 KiB | ||||
33 | Accepted | 1.177s | 66168 KiB | ||||
34 | Accepted | 1.503s | 40824 KiB | ||||
35 | Time limit exceeded | 2.072s | 35572 KiB | ||||
36 | Time limit exceeded | 2.068s | 35380 KiB | ||||
37 | Accepted | 300ms | 62848 KiB | ||||
38 | Time limit exceeded | 2.04s | 34896 KiB | ||||
39 | Accepted | 1.947s | 66400 KiB |