104062024-04-01 20:57:09Valaki2Xorzótáblacpp17Wrong answer 0/1001.746s36512 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();
}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted3ms1840 KiB
2Wrong answer1.45s30576 KiB
subtask20/14
3Wrong answer3ms2248 KiB
4Wrong answer9ms2580 KiB
5Accepted4ms2380 KiB
6Accepted6ms2700 KiB
7Accepted9ms3000 KiB
8Accepted12ms3020 KiB
9Wrong answer14ms3284 KiB
subtask30/14
10Accepted3ms3112 KiB
11Accepted1.583s33632 KiB
12Accepted1.583s32436 KiB
13Wrong answer1.746s34292 KiB
14Wrong answer1.746s34092 KiB
subtask40/14
15Accepted1.12s31712 KiB
16Accepted1.31s32696 KiB
17Wrong answer1.069s31360 KiB
18Accepted1.491s34528 KiB
19Accepted1.475s34660 KiB
subtask50/21
20Wrong answer172ms10964 KiB
21Accepted898ms22444 KiB
22Accepted861ms21936 KiB
23Accepted1.309s33888 KiB
24Accepted1.358s34232 KiB
25Wrong answer1s36496 KiB
subtask60/37
26Accepted118ms7936 KiB
27Wrong answer1.25s31160 KiB
28Wrong answer1.021s21960 KiB
29Accepted1.427s32156 KiB
30Accepted1.741s34968 KiB
31Accepted1.746s34988 KiB
32Accepted1.192s36512 KiB
33Wrong answer1.741s36064 KiB
34Accepted1.743s36056 KiB