답안 #141197

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
141197 2019-08-07T06:13:35 Z meatrow XOR Sum (info1cup17_xorsum) C++17
100 / 100
754 ms 11148 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 = 30;
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;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 455 ms 11148 KB Output is correct
2 Correct 428 ms 10428 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 455 ms 11148 KB Output is correct
2 Correct 428 ms 10428 KB Output is correct
3 Correct 545 ms 11148 KB Output is correct
4 Correct 527 ms 10768 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 82 ms 1464 KB Output is correct
4 Correct 82 ms 1372 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 455 ms 11148 KB Output is correct
4 Correct 428 ms 10428 KB Output is correct
5 Correct 545 ms 11148 KB Output is correct
6 Correct 527 ms 10768 KB Output is correct
7 Correct 82 ms 1464 KB Output is correct
8 Correct 82 ms 1372 KB Output is correct
9 Correct 749 ms 11136 KB Output is correct
10 Correct 748 ms 11148 KB Output is correct
11 Correct 754 ms 11092 KB Output is correct