105512024-04-05 12:32:24CWMXorzótáblacpp17Time limit exceeded 14/1002.099s6168 KiB
#include <iostream>
#include <vector>
#include <set>
#include <queue>
#include <algorithm>
#include <climits>

using namespace std;
long long cMod = 2;
int bitlookahead = 1;

bool comp(int a, int b) {
    a = a % cMod;
    b = b % cMod;
    return b > a;
}

signed main()
{
    int sA, sB;
    cin >> sA >> sB;
    vector<int> a(sA);
    vector<int> b(sB);
    for (size_t i = 0; i < sA; i++)
    {
        cin >> a[i];
    }
    for (size_t i = 0; i < sB; i++)
    {
        cin >> b[i];
    }
    long long res = 0;
    while (cMod<4e9)
    {
        sort(a.begin(), a.end(), comp);
        sort(b.begin(), b.end(), comp);
        vector<int> aTemp(sA);
        vector<int> bTemp(sB);
        for (size_t i = 0; i < sA; i++)
        {
            aTemp[i] = a[i] % cMod;
        }
        for (size_t i = 0; i < sB; i++)
        {
            bTemp[i] = b[i] % cMod;
        }
        long long lLim = cMod / 2;
        long long uLim = cMod;
        int ans = 0;
        for (size_t i = 0; i < aTemp.size(); i++)
        {
            int lIdx = lower_bound(bTemp.begin(), bTemp.end(), lLim - aTemp[i]) - bTemp.begin();
            int uIdx = lower_bound(bTemp.begin(), bTemp.end(), uLim - aTemp[i]) - bTemp.begin();
            int ulIdx = lower_bound(bTemp.begin(), bTemp.end(), uLim+lLim - aTemp[i]) - bTemp.begin();
            int cDif = uIdx - lIdx + bTemp.size()-ulIdx;
            ans += cDif;
        }
        if (ans % 2 == 1) {
            res += cMod;
        }
        cMod *= 2;
        bitlookahead++;
    }
    cout << res/2;
    return 0;
}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted3ms1808 KiB
2Time limit exceeded2.099s2716 KiB
subtask214/14
3Accepted3ms2164 KiB
4Accepted14ms2320 KiB
5Accepted14ms2520 KiB
6Accepted8ms2728 KiB
7Accepted23ms2704 KiB
8Accepted21ms2756 KiB
9Accepted29ms2876 KiB
subtask30/14
10Accepted4ms2996 KiB
11Time limit exceeded2.099s4136 KiB
12Time limit exceeded2.099s4156 KiB
13Time limit exceeded2.029s4456 KiB
14Time limit exceeded2.065s4632 KiB
subtask40/14
15Time limit exceeded2.065s4012 KiB
16Time limit exceeded2.053s4320 KiB
17Time limit exceeded2.066s4400 KiB
18Time limit exceeded2.015s4916 KiB
19Time limit exceeded2.062s4944 KiB
subtask50/21
20Accepted527ms4892 KiB
21Accepted1.794s6168 KiB
22Time limit exceeded2.075s4900 KiB
23Time limit exceeded2.065s4976 KiB
24Time limit exceeded2.042s5128 KiB
25Time limit exceeded2.073s5144 KiB
subtask60/37
26Accepted261ms4556 KiB
27Time limit exceeded2.066s4540 KiB
28Time limit exceeded2.062s4712 KiB
29Time limit exceeded2.049s4912 KiB
30Time limit exceeded2.042s5072 KiB
31Time limit exceeded2.049s5176 KiB
32Time limit exceeded2.073s5244 KiB
33Time limit exceeded2.069s5216 KiB
34Time limit exceeded2.058s5208 KiB