Submission #676700

# Submission time Handle Problem Language Result Execution time Memory
676700 2022-12-31T18:06:33 Z LucaLucaM XOR Sum (info1cup17_xorsum) C++17
0 / 100
175 ms 12616 KB
#include <bits/stdc++.h>

using namespace std;

#define int long long
int a[1000001];

/**
bitul b+1 nu influnteaza bitul b la adunare (doar invers)
=> pornim de la b = 30 si vedem cate nr sunt >= 2^29

**/

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int n;
    cin >> n;

    for (int i=0; i<n; i++)
        cin >> a[i];

    long long cnt[31] = {};

    long long ans = 0;

    for (int b=29; b>=0; b--)
    {
        int p = (1 << b);

        for (int i=0; i<n; i++)
        {
            if (a[i] & p)
                a[i] ^= p;
        }

        int l=-1, r=0;
        int sum = 0;

        while (l < n)
        {
            l++;
            sum += a[l];

            while (r < n && sum < p)
                sum += a[r++];
            if (sum < p)
                break;
            cnt[b] += n-r;

            sum -= a[l];
        }

        int curr = cnt[b] - cnt[b+1];
        curr &= 1;

        if (curr)
            ans |= p;
    }

    cout << ans;

    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 175 ms 12616 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 175 ms 12616 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -