5430 | 2023-05-23 16:39:27 | 111 | Xorzótábla | cpp14 | Accepted 100/100 | 1.934s | 34356 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;
}
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Accepted | 3ms | 1808 KiB | ||||
2 | Accepted | 1.597s | 26604 KiB | ||||
subtask2 | 14/14 | ||||||
3 | Accepted | 1.597s | 26604 KiB | ||||
4 | Accepted | 3ms | 2092 KiB | ||||
5 | Accepted | 4ms | 2116 KiB | ||||
6 | Accepted | 6ms | 2756 KiB | ||||
7 | Accepted | 4ms | 2548 KiB | ||||
8 | Accepted | 8ms | 3064 KiB | ||||
9 | Accepted | 9ms | 3048 KiB | ||||
10 | Accepted | 12ms | 3464 KiB | ||||
subtask3 | 14/14 | ||||||
11 | Accepted | 12ms | 3464 KiB | ||||
12 | Accepted | 3ms | 3268 KiB | ||||
13 | Accepted | 1.371s | 31760 KiB | ||||
14 | Accepted | 1.697s | 31548 KiB | ||||
15 | Accepted | 1.899s | 34356 KiB | ||||
16 | Accepted | 1.899s | 31836 KiB | ||||
subtask4 | 14/14 | ||||||
17 | Accepted | 1.899s | 31836 KiB | ||||
18 | Accepted | 372ms | 18240 KiB | ||||
19 | Accepted | 560ms | 30604 KiB | ||||
20 | Accepted | 634ms | 33096 KiB | ||||
21 | Accepted | 683ms | 33260 KiB | ||||
22 | Accepted | 697ms | 33248 KiB | ||||
subtask5 | 21/21 | ||||||
23 | Accepted | 697ms | 33248 KiB | ||||
24 | Accepted | 92ms | 9896 KiB | ||||
25 | Accepted | 352ms | 16528 KiB | ||||
26 | Accepted | 524ms | 31596 KiB | ||||
27 | Accepted | 589ms | 29248 KiB | ||||
28 | Accepted | 629ms | 31704 KiB | ||||
29 | Accepted | 340ms | 31860 KiB | ||||
subtask6 | 37/37 | ||||||
30 | Accepted | 340ms | 31860 KiB | ||||
31 | Accepted | 72ms | 7748 KiB | ||||
32 | Accepted | 1.088s | 11304 KiB | ||||
33 | Accepted | 1.22s | 32140 KiB | ||||
34 | Accepted | 1.411s | 22048 KiB | ||||
35 | Accepted | 1.902s | 33132 KiB | ||||
36 | Accepted | 1.934s | 32592 KiB | ||||
37 | Accepted | 370ms | 32160 KiB | ||||
38 | Accepted | 1.893s | 33316 KiB | ||||
39 | Accepted | 1.878s | 33388 KiB |