10403 | 2024-04-01 20:51:09 | Valaki2 | Xorzótábla | cpp17 | Wrong answer 0/100 | 1.699s | 69908 KiB |
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define fi first
#define se second
const int maxn = 1e5;
int n, m;
int a[1 + maxn];
int b[1 + maxn];
int len;
int halflen;
struct event {
int type;
// 0 - update
// 1 - query
int pos;
bool operator < (const event &other) const {
if(pos == other.pos) {
return type < other.type;
}
return pos < other.pos;
}
};
int get_bit(int bit) {
len = (1 << (bit + 1));
halflen = (1 << bit);
vector<event> events;
for(int i = 1; i <= m; i++) {
int bi = b[i] % len;
int l = (halflen - bi + 2 * len) % len;
int r = (len - 1 - bi + 2 * len) % len;
if(l == 0) {
events.pb(event{1, r});
} else {
if(l < r) {
events.pb(event{1, l - 1});
events.pb(event{1, r});
} else {
events.pb(event{1, r});
events.pb(event{1, l - 1});
events.pb(event{1, len - 1});
}
}
}
for(int i = 1; i <= n; i++) {
int ai = a[i] % len;
events.pb(event{0, ai});
}
sort(events.begin(), events.end());
int res = 0;
int cnt = 0;
for(event e : events) {
if(e.type == 0) {
cnt++;
cnt %= 2;
} else {
res += cnt;
}
}
res %= 2;
return res;
}
void solve() {
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 j = 0; j < 30; j++) {
ans += (get_bit(j) << j);
}
cout << ans << "\n";
}
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
solve();
}
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Accepted | 3ms | 1832 KiB | ||||
2 | Wrong answer | 1.417s | 32236 KiB | ||||
subtask2 | 0/14 | ||||||
3 | Wrong answer | 3ms | 3904 KiB | ||||
4 | Wrong answer | 9ms | 4372 KiB | ||||
5 | Accepted | 4ms | 4260 KiB | ||||
6 | Accepted | 6ms | 4552 KiB | ||||
7 | Accepted | 9ms | 4952 KiB | ||||
8 | Accepted | 12ms | 5188 KiB | ||||
9 | Wrong answer | 14ms | 5428 KiB | ||||
subtask3 | 0/14 | ||||||
10 | Accepted | 3ms | 5400 KiB | ||||
11 | Accepted | 1.608s | 36956 KiB | ||||
12 | Accepted | 1.475s | 37364 KiB | ||||
13 | Wrong answer | 1.625s | 40928 KiB | ||||
14 | Wrong answer | 1.625s | 42864 KiB | ||||
subtask4 | 0/14 | ||||||
15 | Accepted | 1.093s | 41736 KiB | ||||
16 | Accepted | 1.269s | 44544 KiB | ||||
17 | Wrong answer | 1.034s | 44464 KiB | ||||
18 | Accepted | 1.434s | 49544 KiB | ||||
19 | Accepted | 1.421s | 51380 KiB | ||||
subtask5 | 0/21 | ||||||
20 | Wrong answer | 167ms | 27728 KiB | ||||
21 | Accepted | 869ms | 39848 KiB | ||||
22 | Accepted | 820ms | 39720 KiB | ||||
23 | Accepted | 1.266s | 52404 KiB | ||||
24 | Accepted | 1.312s | 53392 KiB | ||||
25 | Wrong answer | 972ms | 56016 KiB | ||||
subtask6 | 0/37 | ||||||
26 | Accepted | 114ms | 27680 KiB | ||||
27 | Wrong answer | 1.271s | 52160 KiB | ||||
28 | Wrong answer | 1.016s | 44548 KiB | ||||
29 | Accepted | 1.315s | 56096 KiB | ||||
30 | Accepted | 1.689s | 60824 KiB | ||||
31 | Accepted | 1.623s | 62724 KiB | ||||
32 | Accepted | 1.085s | 66264 KiB | ||||
33 | Wrong answer | 1.699s | 67928 KiB | ||||
34 | Accepted | 1.623s | 69908 KiB |