#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize ("unroll-loops,Ofast,O3")
#pragma GCC target("avx,avx2,fma")
#define F first
#define S second
#define int long long
#define sz(x) (int)x.size()
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define NFS ios_base::sync_with_stdio(0) , cin.tie(0) , cout.tie(0) ;
#define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)
const int E = (int)1e6+777;
const int N = (int)4e3+12;
int n, a[E];
void solve1(int res = 0){
for(int i = 1; i <= n; ++i){
for(int j = i; j <= n; ++j){
res ^= (a[i] + a[j]);
}
}
cout << res;
exit(false);
}
void solve2(int res = 0){
vector<int> cnt(N, 0), s(N+N+2,0);
for(int i = 1; i <= n; ++i){
++cnt[a[i]];
}
for(int i = 1; i <= N; ++i){
for(int j = i; j <= N; ++j){
if(i == j && cnt[i]){
// cerr << "i: " << i << " cnt[i]: " << cnt[i] << '\n';
s[i+j] += cnt[i] * (cnt[i] + 1) / 2;
}else if(cnt[i] & cnt[j]){
// cerr << "i: " << i << " cnt[i]: " << cnt[i] << " j: " << j << " cnt[j]: " << j << '\n';
s[i+j] += cnt[i] * cnt[j];
}
}
}
for(int i = 1; i <= (int)8e3; ++i){
if(s[i] & 1){
// cerr << "i: " << i << " sm[i]: " << s[i] << '\n';
res ^= i;
}
}
cout << res;
exit(false);
}
signed main(){
cin >> n;
for(int i = 1; i <= n; ++i){
cin >> a[i];
}
if(n <= 1e5){
solve1();
}
solve2();
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
204 KB |
Output is correct |
2 |
Correct |
3 ms |
332 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
230 ms |
8116 KB |
Output is correct |
2 |
Correct |
207 ms |
7580 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
230 ms |
8116 KB |
Output is correct |
2 |
Correct |
207 ms |
7580 KB |
Output is correct |
3 |
Runtime error |
274 ms |
16388 KB |
Execution killed with signal 11 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
204 KB |
Output is correct |
2 |
Correct |
3 ms |
332 KB |
Output is correct |
3 |
Correct |
1106 ms |
1060 KB |
Output is correct |
4 |
Correct |
1045 ms |
1064 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
204 KB |
Output is correct |
2 |
Correct |
3 ms |
332 KB |
Output is correct |
3 |
Correct |
230 ms |
8116 KB |
Output is correct |
4 |
Correct |
207 ms |
7580 KB |
Output is correct |
5 |
Runtime error |
274 ms |
16388 KB |
Execution killed with signal 11 |
6 |
Halted |
0 ms |
0 KB |
- |