제출 #1308447

#제출 시각아이디문제언어결과실행 시간메모리
1308447mxhrvsXOR Sum (info1cup17_xorsum)C++20
45 / 100
1694 ms12180 KiB
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
    // Giriş çıkış hızlandırma
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n;
    cin >> n;

    vector<int> v(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }

    long long ans = 0;

    for (int k = 0; k < 30; ++k) {
        long long mod = 1LL << (k + 1);
        long long lower_bound_bit = 1LL << k;

        vector<long long> current_bits(n);
        for (int i = 0; i < n; ++i) {
            current_bits[i] = v[i] % mod;
        }
        
        sort(current_bits.begin(), current_bits.end());

        long long count = 0;
        for (int i = 0; i < n; ++i) {
            long long x = current_bits[i];

            long long l1 = lower_bound_bit - x;
            long long r1 = (2 * lower_bound_bit) - 1 - x;
            
            long long l2 = (3 * lower_bound_bit) - x;
            long long r2 = (4 * lower_bound_bit) - 1 - x;

           
            count += upper_bound(current_bits.begin() + i, current_bits.end(), r1) - 
                     lower_bound(current_bits.begin() + i, current_bits.end(), l1);
            
            count += upper_bound(current_bits.begin() + i, current_bits.end(), r2) - 
                     lower_bound(current_bits.begin() + i, current_bits.end(), l2);
        }

        if (count % 2 == 1) {
            ans |= lower_bound_bit;
        }
    }

    cout << ans << endl;

    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...