10408 | 2024-04-01 21:13:55 | Valaki2 | Xorzótábla | cpp17 | Time limit exceeded 49/100 | 2.084s | 36632 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 = (1ll << (bit + 1));
halflen = (1ll << 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) {
//cout << e.type << " " << e.pos << "; ";
if(e.type == 0) {
cnt++;
cnt %= 2;
} else {
res += cnt;
}
}
//cout << " - ";
res %= 2;
//cout << bit << " " << res << " - " << (((int) 1e9 >> bit) & 1) << "\n";
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 < 40; 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 | 1984 KiB | ||||
2 | Accepted | 1.791s | 30708 KiB | ||||
subtask2 | 14/14 | ||||||
3 | Accepted | 3ms | 2136 KiB | ||||
4 | Accepted | 12ms | 2516 KiB | ||||
5 | Accepted | 6ms | 2648 KiB | ||||
6 | Accepted | 7ms | 2840 KiB | ||||
7 | Accepted | 10ms | 2936 KiB | ||||
8 | Accepted | 14ms | 2952 KiB | ||||
9 | Accepted | 16ms | 3220 KiB | ||||
subtask3 | 0/14 | ||||||
10 | Accepted | 3ms | 3188 KiB | ||||
11 | Time limit exceeded | 2.038s | 33436 KiB | ||||
12 | Accepted | 1.916s | 32264 KiB | ||||
13 | Time limit exceeded | 2.069s | 17764 KiB | ||||
14 | Time limit exceeded | 2.062s | 17816 KiB | ||||
subtask4 | 14/14 | ||||||
15 | Accepted | 1.381s | 31420 KiB | ||||
16 | Accepted | 1.705s | 32280 KiB | ||||
17 | Accepted | 1.342s | 30848 KiB | ||||
18 | Accepted | 1.853s | 33760 KiB | ||||
19 | Accepted | 1.848s | 33700 KiB | ||||
subtask5 | 21/21 | ||||||
20 | Accepted | 221ms | 10388 KiB | ||||
21 | Accepted | 1.118s | 22056 KiB | ||||
22 | Accepted | 1.103s | 21600 KiB | ||||
23 | Accepted | 1.593s | 33480 KiB | ||||
24 | Accepted | 1.728s | 34140 KiB | ||||
25 | Accepted | 1.274s | 36008 KiB | ||||
subtask6 | 0/37 | ||||||
26 | Accepted | 148ms | 7504 KiB | ||||
27 | Accepted | 1.595s | 30908 KiB | ||||
28 | Accepted | 1.335s | 21892 KiB | ||||
29 | Accepted | 1.702s | 32076 KiB | ||||
30 | Time limit exceeded | 2.062s | 19204 KiB | ||||
31 | Time limit exceeded | 2.071s | 19104 KiB | ||||
32 | Accepted | 1.381s | 36632 KiB | ||||
33 | Time limit exceeded | 2.084s | 19732 KiB | ||||
34 | Time limit exceeded | 2.059s | 19788 KiB |