답안 #999490

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
999490 2024-06-15T15:31:54 Z LOLOLO XOR Sum (info1cup17_xorsum) C++17
0 / 100
17 ms 4444 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 = 3e5 + 10;
int a[N];

int is(vector <int> v, int k) {
    vector <ll> cnt(3, 0);
    for (auto x : v) {
        int c = 0;
        if (x & (1 << k))
            c |= 2;

        if (k && (x & (1 << (k - 1))))
            c |= 1;

        cnt[c]++;
    }

    ll cc = 0;
    for (int i = 0; i < 3; i++) {
        for (int j = i + 1; j < 3; j++) {
            if ((i + j) & 2) {
                cc += cnt[i] * cnt[j];
            }
        }
    }

    return cc % 2;
}

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

    int n;
    cin >> n;

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

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

        if (is(v, j)) 
            ans |= (1 << (j - 1));        
    }

    ans ^= all;
    cout << ans << '\n';
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 17 ms 4444 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 17 ms 4444 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -