5554 | 2023-07-25 12:45:08 | szil | Xorzótábla | cpp17 | Accepted 100/100 | 1.218s | 11036 KiB |
#include <bits/stdc++.h>
#define int long long
using ll = long long;
using namespace std;
const int MAXN = 100010;
int a[MAXN], b[MAXN], p[MAXN], q[MAXN];
signed main() {
ios::sync_with_stdio(0); cin.tie(0);
int n, m; cin >> n >> m;
for (int i = 1; i <= n; i++) cin >> a[i];
for (int i = 1; i <= m; i++) cin >> b[i];
int ans = 0;
for (int k = 0; k < 31; k++) {
int x = 1LL<<k, y = 1LL<<(k+1);
for (int j = 1; j <= n; j++) {
p[j] = a[j] % y;
}
for (int j = 1; j <= m; j++) {
q[j] = b[j] % y;
}
sort(q+1, q+m+1);
ll cnt = 0;
for (int j = 1; j <= n; j++) {
{
int left = lower_bound(q+1, q+m+1, x-p[j])-q;
int right = lower_bound(q+1, q+m+1, y-p[j])-q;
cnt += right-left;
}
{
int left = lower_bound(q+1, q+m+1, (x+y)-p[j])-q;
cnt += m-left+1;
}
}
if (cnt&1)
ans |= 1 << k;
}
cout << ans << "\n";
return 0;
}
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Accepted | 3ms | 1948 KiB | ||||
2 | Accepted | 994ms | 7492 KiB | ||||
subtask2 | 14/14 | ||||||
3 | Accepted | 3ms | 2504 KiB | ||||
4 | Accepted | 4ms | 2736 KiB | ||||
5 | Accepted | 4ms | 2948 KiB | ||||
6 | Accepted | 4ms | 3132 KiB | ||||
7 | Accepted | 8ms | 3104 KiB | ||||
8 | Accepted | 7ms | 3424 KiB | ||||
9 | Accepted | 9ms | 3672 KiB | ||||
subtask3 | 14/14 | ||||||
10 | Accepted | 3ms | 3336 KiB | ||||
11 | Accepted | 954ms | 9772 KiB | ||||
12 | Accepted | 1.085s | 9376 KiB | ||||
13 | Accepted | 1.218s | 9932 KiB | ||||
14 | Accepted | 1.215s | 10216 KiB | ||||
subtask4 | 14/14 | ||||||
15 | Accepted | 409ms | 8640 KiB | ||||
16 | Accepted | 509ms | 9664 KiB | ||||
17 | Accepted | 456ms | 9420 KiB | ||||
18 | Accepted | 546ms | 10344 KiB | ||||
19 | Accepted | 533ms | 10484 KiB | ||||
subtask5 | 21/21 | ||||||
20 | Accepted | 82ms | 5396 KiB | ||||
21 | Accepted | 307ms | 8420 KiB | ||||
22 | Accepted | 414ms | 9568 KiB | ||||
23 | Accepted | 493ms | 10568 KiB | ||||
24 | Accepted | 523ms | 11036 KiB | ||||
25 | Accepted | 395ms | 10712 KiB | ||||
subtask6 | 37/37 | ||||||
26 | Accepted | 59ms | 5064 KiB | ||||
27 | Accepted | 474ms | 8304 KiB | ||||
28 | Accepted | 994ms | 9292 KiB | ||||
29 | Accepted | 810ms | 9332 KiB | ||||
30 | Accepted | 1.218s | 10804 KiB | ||||
31 | Accepted | 1.218s | 10848 KiB | ||||
32 | Accepted | 360ms | 10816 KiB | ||||
33 | Accepted | 1.194s | 10784 KiB | ||||
34 | Accepted | 1.197s | 10812 KiB |