167342025-05-11 22:08:11BucsMateXorzótáblacpp17Wrong answer 0/100992ms3920 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 < 30; mask++){
        //bitenkent megszamoljuk hany 1-es van
        int 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());
        int 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
1Accepted1ms316 KiB
2Wrong answer828ms3380 KiB
subtask20/14
3Wrong answer1ms316 KiB
4Wrong answer3ms316 KiB
5Accepted4ms316 KiB
6Accepted2ms320 KiB
7Accepted7ms432 KiB
8Accepted6ms316 KiB
9Wrong answer8ms432 KiB
subtask30/14
10Accepted2ms316 KiB
11Accepted892ms3312 KiB
12Wrong answer890ms3564 KiB
13Wrong answer991ms3908 KiB
14Wrong answer990ms3892 KiB
subtask40/14
15Accepted470ms2720 KiB
16Wrong answer642ms3468 KiB
17Wrong answer651ms3304 KiB
18Accepted728ms3832 KiB
19Accepted727ms3824 KiB
subtask50/21
20Accepted96ms980 KiB
21Accepted344ms1588 KiB
22Wrong answer518ms2056 KiB
23Wrong answer593ms2428 KiB
24Accepted634ms2544 KiB
25Accepted430ms2756 KiB
subtask60/37
26Accepted68ms564 KiB
27Accepted458ms2396 KiB
28Wrong answer769ms3052 KiB
29Wrong answer702ms3032 KiB
30Accepted992ms3896 KiB
31Accepted990ms3892 KiB
32Accepted384ms3920 KiB
33Wrong answer985ms3916 KiB
34Wrong answer985ms3920 KiB