/*#pragma GCC optimize("O3")
#pragma GCC target ("avx2")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")*/
#include <bits/stdc++.h>
#define file(data) freopen(data".in", "r", stdin); freopen(data".out", "w", stdout);
#define pb push_back
#define ios ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define all(data) data.begin() , data.end()
#define endl '\n'
//freopen("nenokku_easy.in", "r", stdin);
//freopen("nenokku_easy.out", "w", stdout);
#define int long long
#define pii pair < int, int >
#define pll pair < long long, long long >
using namespace std;
typedef long long ll;
const int N = 1e6 + 5;
const int M = 350;
const int mod = 1e9 + 7;
int n, v[N], used[N];
main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
//file("pieaters");
cin >> n;
for(int i = 1; i <= n; i++) {
cin >> v[i];
}
if(n <= 5000) {
int ans = 0;
for(int i = 1; i <= n; i++) {
for(int j = i; j <= n; j++) {
ans ^= (v[i] + v[j]);
}
}
cout << ans;
} else {
for(int i = 1; i <= n; i++) {
used[v[i]]++;
}
int ans = 0;
for(int i = 1; i <= 4000; i++) {
if(used[i] == 0) continue;
int cnt = used[i] * (used[i] + 1) / 2;
if(cnt % 2) ans ^= (i * 2);
//cout << cnt << " " << i << endl;
for(int j = i + 1; j <= 4000; j++) {
if(used[j] == 0) continue;
cnt = used[i] * used[j];
if(cnt % 2) ans ^= (i + j);
}
}
cout << ans;
}
}
/*
5 9 7
...##....
..#.##..#
..#....##
.##...#..
....#....
WS?EE??
*/
Compilation message
xorsum.cpp:27:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
27 | main() {
| ^~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
356 KB |
Output is correct |
2 |
Correct |
5 ms |
332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
72 ms |
8164 KB |
Output is correct |
2 |
Correct |
72 ms |
7572 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
72 ms |
8164 KB |
Output is correct |
2 |
Correct |
72 ms |
7572 KB |
Output is correct |
3 |
Incorrect |
97 ms |
15932 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
356 KB |
Output is correct |
2 |
Correct |
5 ms |
332 KB |
Output is correct |
3 |
Runtime error |
11 ms |
1996 KB |
Execution killed with signal 11 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
356 KB |
Output is correct |
2 |
Correct |
5 ms |
332 KB |
Output is correct |
3 |
Correct |
72 ms |
8164 KB |
Output is correct |
4 |
Correct |
72 ms |
7572 KB |
Output is correct |
5 |
Incorrect |
97 ms |
15932 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |