167382025-05-11 22:43:58BucsMateXorzótáblacpp17Accepted 100/1001.059s1984 KiB
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
    int N, M;

    cin >> N >> M;
    vector<int> A(N), B(M);

    for(int i = 0; i < N; i++){
        cin >> A[i];
    }
    for(int i = 0; i < M; i++){
        cin >> B[i];
    }

    long long ans = 0;
    for(int mask = 0; mask < 31; mask++){
        //bitenkent meghatarozzuk az 1-esek szamat
        long long x = (1LL << mask), y = (1LL << (mask+1));
        vector<int> tempA(N), tempB(M);
        for (int i = 0; i < N; i++) {
            tempA[i] = A[i] % y;
        }
        for (int i = 0; i < M; i++) {
            tempB[i] = B[i] % y;
        }
        sort(tempA.begin(), tempA.end());
        sort(tempB.begin(), tempB.end());
        long long cnt = 0;

        for(int j = 0; j < N; j++){
            int left = lower_bound(tempB.begin(), tempB.end(), x-tempA[j])-tempB.begin();
            int right = lower_bound(tempB.begin(), tempB.end(), y-tempA[j])-tempB.begin();
            int valami = lower_bound(tempB.begin(), tempB.end(), (x+y)-tempA[j])-tempB.begin();
            //a valami azert kell, mert lehet tulcsordulas a kovetkezo bitbe
            cnt += right-left + M - valami;
        }
        if(cnt % 2 == 1){
            ans += (1 << mask);
        }
    }
    cout << ans << endl;

    return 0;
}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted1ms500 KiB
2Accepted885ms1724 KiB
subtask214/14
3Accepted1ms316 KiB
4Accepted4ms316 KiB
5Accepted4ms316 KiB
6Accepted2ms508 KiB
7Accepted8ms408 KiB
8Accepted7ms316 KiB
9Accepted9ms416 KiB
subtask314/14
10Accepted1ms316 KiB
11Accepted949ms1972 KiB
12Accepted953ms1816 KiB
13Accepted1.059s1972 KiB
14Accepted1.059s1972 KiB
subtask414/14
15Accepted503ms1532 KiB
16Accepted688ms1780 KiB
17Accepted700ms1728 KiB
18Accepted783ms1956 KiB
19Accepted782ms1968 KiB
subtask521/21
20Accepted104ms892 KiB
21Accepted370ms1332 KiB
22Accepted558ms1540 KiB
23Accepted635ms1892 KiB
24Accepted680ms1964 KiB
25Accepted479ms1984 KiB
subtask637/37
26Accepted71ms548 KiB
27Accepted486ms1332 KiB
28Accepted833ms1512 KiB
29Accepted749ms1704 KiB
30Accepted1.059s1964 KiB
31Accepted1.057s1964 KiB
32Accepted521ms1964 KiB
33Accepted1.05s1964 KiB
34Accepted1.05s1964 KiB