Submission #999506

# Submission time Handle Problem Language Result Execution time Memory
999506 2024-06-15T16:13:05 Z LOLOLO XOR Sum (info1cup17_xorsum) C++14
56 / 100
1600 ms 8136 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
#define           f     first
#define           s     second
#define           pb    push_back
#define           ep    emplace
#define           eb    emplace_back
#define           lb    lower_bound
#define           ub    upper_bound
#define       all(x)    x.begin(), x.end()
#define      rall(x)    x.rbegin(), x.rend()
#define   uniquev(v)    sort(all(v)), (v).resize(unique(all(v)) - (v).begin())
#define     mem(f,x)    memset(f , x , sizeof(f))
#define        sz(x)    (ll)(x).size()
#define  __lcm(a, b)    (1ll * ((a) / __gcd((a), (b))) * (b))
#define          mxx    *max_element
#define          mnn    *min_element
#define    cntbit(x)    __builtin_popcountll(x)
#define       len(x)    (int)(x.length())
 
const int N = 1e6 + 10;
int a[N], n, v[N];

ll cal(int t) {
    ll ans = 0;
    int p = n;

    for (int i = 1; i <= n; i++) {
        while (p - 1 >= 1 && v[i] + v[p - 1] >= t)
            p--;

        if (v[i] + v[p] >= t)
            ans += max(0, i - p + 1);
    }

    return ans;
}

int is(int j) {
    ll t = cal((1 << (j + 1)) | ((1 << j))) + cal((1 << (j + 1))) - cal(1 << j);
    return t % 2;
}

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

    cin >> n;

    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }

    int ans = 0;
    for (int j = 0; j < 30; j++) {
        for (int i = 1; i <= n; i++) {
            v[i] = (a[i] % (1 << ((j + 1))));
        }

        sort(v + 1, v + 1 + n);
        if (is(j))
            ans |= (1 << j);
    }

    cout << ans << '\n';
    return 0;
}
/*
011
011
*/
# Verdict Execution time Memory Grader output
1 Correct 8 ms 2392 KB Output is correct
2 Correct 7 ms 2396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1494 ms 8136 KB Output is correct
2 Correct 1378 ms 7992 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1494 ms 8136 KB Output is correct
2 Correct 1378 ms 7992 KB Output is correct
3 Execution timed out 1643 ms 8016 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 8 ms 2392 KB Output is correct
2 Correct 7 ms 2396 KB Output is correct
3 Correct 187 ms 6748 KB Output is correct
4 Correct 188 ms 6744 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 2392 KB Output is correct
2 Correct 7 ms 2396 KB Output is correct
3 Correct 1494 ms 8136 KB Output is correct
4 Correct 1378 ms 7992 KB Output is correct
5 Execution timed out 1643 ms 8016 KB Time limit exceeded
6 Halted 0 ms 0 KB -