#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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |