10406 | 2024-04-01 20:57:09 | Valaki2 | Xorzótábla | cpp17 | Wrong answer 0/100 | 1.746s | 36512 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 < 31; 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 | 1840 KiB | ||||
2 | Wrong answer | 1.45s | 30576 KiB | ||||
subtask2 | 0/14 | ||||||
3 | Wrong answer | 3ms | 2248 KiB | ||||
4 | Wrong answer | 9ms | 2580 KiB | ||||
5 | Accepted | 4ms | 2380 KiB | ||||
6 | Accepted | 6ms | 2700 KiB | ||||
7 | Accepted | 9ms | 3000 KiB | ||||
8 | Accepted | 12ms | 3020 KiB | ||||
9 | Wrong answer | 14ms | 3284 KiB | ||||
subtask3 | 0/14 | ||||||
10 | Accepted | 3ms | 3112 KiB | ||||
11 | Accepted | 1.583s | 33632 KiB | ||||
12 | Accepted | 1.583s | 32436 KiB | ||||
13 | Wrong answer | 1.746s | 34292 KiB | ||||
14 | Wrong answer | 1.746s | 34092 KiB | ||||
subtask4 | 0/14 | ||||||
15 | Accepted | 1.12s | 31712 KiB | ||||
16 | Accepted | 1.31s | 32696 KiB | ||||
17 | Wrong answer | 1.069s | 31360 KiB | ||||
18 | Accepted | 1.491s | 34528 KiB | ||||
19 | Accepted | 1.475s | 34660 KiB | ||||
subtask5 | 0/21 | ||||||
20 | Wrong answer | 172ms | 10964 KiB | ||||
21 | Accepted | 898ms | 22444 KiB | ||||
22 | Accepted | 861ms | 21936 KiB | ||||
23 | Accepted | 1.309s | 33888 KiB | ||||
24 | Accepted | 1.358s | 34232 KiB | ||||
25 | Wrong answer | 1s | 36496 KiB | ||||
subtask6 | 0/37 | ||||||
26 | Accepted | 118ms | 7936 KiB | ||||
27 | Wrong answer | 1.25s | 31160 KiB | ||||
28 | Wrong answer | 1.021s | 21960 KiB | ||||
29 | Accepted | 1.427s | 32156 KiB | ||||
30 | Accepted | 1.741s | 34968 KiB | ||||
31 | Accepted | 1.746s | 34988 KiB | ||||
32 | Accepted | 1.192s | 36512 KiB | ||||
33 | Wrong answer | 1.741s | 36064 KiB | ||||
34 | Accepted | 1.743s | 36056 KiB |