Submission #141195

# Submission time Handle Problem Language Result Execution time Memory
141195 2019-08-07T06:12:52 Z meatrow XOR Sum (info1cup17_xorsum) C++17
77 / 100
733 ms 19412 KB
//#pragma GCC optimize("O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native")
//#pragma GCC optimize ("unroll-loops")
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using ld = long double;

const int M = 29;
const int N = 1e6;

int a[N];
int k[2];
int y[2][N];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    int ans = 0;
    int pw = 1;
    for (int b = 0; b < M; b++) {
        int q = (pw << 1) - 1;
        int kek = 0;
        k[0] = k[1] = 0;
        for (int i = 0; i < n; i++) {
            y[(a[i] >> b) & 1][k[(a[i] >> b) & 1]++] = a[i];
        }
        int p = 0;
        for (int i = 0; i < 2; i++) {
            memcpy(a + p, y[i], sizeof(int) * k[i]);
            p += k[i];
        }
        int it1 = n - 1;
        int it2 = n - 1;
        int it3 = n - 1;
        for (int i = 0; i < n; i++) {
            int t = a[i] & q;
            while (it1 >= 0 && (a[it1] & q) >= pw - t) {
                it1--;
            }
            while (it2 >= 0 && (a[it2] & q) > q - t) {
                it2--;
            }
            while (it3 >= 0 && (a[it3] & q) >= 3 * pw - t) {
                it3--;
            }
            (kek += max(0, min(it2, i) - it1)) &= 1;
            if (t & pw) {
                (kek += max(0, i - it3)) &= 1;
            }
        }
        if (kek) {
            ans += pw;
        }
        pw <<= 1;
    }
    cout << ans;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 348 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 451 ms 11156 KB Output is correct
2 Correct 416 ms 14724 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 451 ms 11156 KB Output is correct
2 Correct 416 ms 14724 KB Output is correct
3 Correct 540 ms 17820 KB Output is correct
4 Correct 518 ms 17268 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 348 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 82 ms 1348 KB Output is correct
4 Correct 84 ms 2272 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 348 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 451 ms 11156 KB Output is correct
4 Correct 416 ms 14724 KB Output is correct
5 Correct 540 ms 17820 KB Output is correct
6 Correct 518 ms 17268 KB Output is correct
7 Correct 82 ms 1348 KB Output is correct
8 Correct 84 ms 2272 KB Output is correct
9 Correct 733 ms 19412 KB Output is correct
10 Correct 731 ms 19400 KB Output is correct
11 Incorrect 731 ms 19396 KB Output isn't correct