104092024-04-01 21:15:18Valaki2Xorzótáblacpp17Elfogadva 100/1001.715s35924 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 < 32; j++) {
        ans += (get_bit(j) << j);
    }
    cout << ans << "\n";
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    solve();
}
RészfeladatÖsszpontTesztVerdiktIdőMemória
subtask10/0
1Elfogadva3ms2000 KiB
2Elfogadva1.672s30624 KiB
subtask214/14
3Elfogadva3ms2320 KiB
4Elfogadva9ms2800 KiB
5Elfogadva6ms3000 KiB
6Elfogadva6ms2984 KiB
7Elfogadva9ms3320 KiB
8Elfogadva12ms3468 KiB
9Elfogadva14ms3624 KiB
subtask314/14
10Elfogadva3ms3436 KiB
11Elfogadva1.664s34128 KiB
12Elfogadva1.555s32640 KiB
13Elfogadva1.708s33992 KiB
14Elfogadva1.708s33984 KiB
subtask414/14
15Elfogadva1.111s31628 KiB
16Elfogadva1.345s32668 KiB
17Elfogadva1.077s31012 KiB
18Elfogadva1.455s34116 KiB
19Elfogadva1.444s34128 KiB
subtask521/21
20Elfogadva177ms10576 KiB
21Elfogadva896ms22096 KiB
22Elfogadva861ms21520 KiB
23Elfogadva1.269s33672 KiB
24Elfogadva1.315s33948 KiB
25Elfogadva950ms35908 KiB
subtask637/37
26Elfogadva119ms7336 KiB
27Elfogadva1.276s30584 KiB
28Elfogadva1.054s21364 KiB
29Elfogadva1.386s31444 KiB
30Elfogadva1.712s34424 KiB
31Elfogadva1.715s34344 KiB
32Elfogadva1.141s35924 KiB
33Elfogadva1.71s35524 KiB
34Elfogadva1.715s35740 KiB