제출 #1139835

#제출 시각아이디문제언어결과실행 시간메모리
1139835PersiaXOR Sum (info1cup17_xorsum)C++20
18 / 100
1693 ms4168 KiB
#include <bits/stdc++.h>
#define bit(i, x) (x >> i & 1)
#define ll long long
const int N = 2e5 + 5;
const int mod = 998244353;
using namespace std;

int n;
vector<int> a;

int subtask1() {
    int res = 0;
    for(int i = 1; i <= n; i++) {
        for(int j = i; j <= n; j++) {
            int x = a[i] + a[j];
            res = (res ^ x);
        }
    }
    return res;
}

int subtask2() {
    vector<int> cnt(4005);
    int res = 0;
    for(int i = 1; i <= n; i++) cnt[a[i]]++;
    for(int i = 1; i <= 4000; i++) {
        for(int j = i; j <= 4000; j++) {
            ll x = (i == j ? 1LL * cnt[i] * (cnt[i] + 1) / 2 : 1LL * cnt[i] * cnt[j]);
            x %= 2;
            if(x % 2) res ^= (i + j);
        }
    }
    return res;
}

bool check2() {
    return *max_element(a.begin() + 1, a.begin() + n + 1) <= 4000;
}

signed main(int argc, char* argv[]) {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    cin >> n;
    a.assign(n + 3, 0);
    for(int i = 1; i <= n; i++) cin >> a[i];

    if(check2()) cout << subtask2();
    else cout << subtask1();

    return 0 ^ 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...