#include <bits/stdc++.h>
//#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("-O3")
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("fast-math")
//#pragma GCC optimize("no-stack-protector")
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
#define sz(x) int(x.size())
#define all(x) x.begin(),x.end()
#define PB push_back
#define MP make_pair
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pil pair<int, ll>
#define pli pair<ll, int>
#define pdd pair<ld, ld>
#define ft first
#define sd second
using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;
typedef long long ll;
typedef long double ld;
template<class T>
using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
const int N = 400100;
const int M = 100100;
const int BIG = int(5e6);
const int oo = 2e9;
const ll OO = 1e18;
const int md = 998244353;
const int PW = 30;
ll sum;
vector<int> vc;
int a[N], ans = 0, n, mask, mn, mx;
void calc(int x){
int fi = lower_bound(all(vc), mn - x) - vc.begin();
int se = upper_bound(all(vc), mx - x) - vc.begin() - 1;
sum += se - fi + 1;
}
int main() {
#ifdef _LOCAL
freopen("in.txt","r",stdin); //freopen("output.txt","w",stdout);
#else
// freopen("mining.in","r",stdin); freopen("mining.out","w",stdout);
ios_base::sync_with_stdio(0); cin.tie(0);
#endif
cin >> n;
for (int i = 0; i < n; i++)
cin >> a[i];
for (int bt = 0; bt < PW; bt++){
vc.clear();
mask = (1 << (bt + 1)) - 1;
for (int i = 0; i < n; i++)
vc.PB(a[i] & mask);
sort(all(vc));
sum = 0;
for (int cr : vc){
mn = (1 << bt);
mx = (1 << (bt + 1)) - 1;
calc(cr);
if (cr + cr >= mn && cr + cr <= mx)
sum--;
mn += (1 << (bt + 1));
mx = (1 << (bt + 2)) - 2;
calc(cr);
if (cr + cr >= mn && cr + cr <= mx)
sum--;
}
sum /= 2;
if (sum & 1)
ans += (1 << bt);
}
for (int i = 0; i < n; i++)
ans ^= (a[i] + a[i]);
cout << ans;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
26 ms |
384 KB |
Output is correct |
2 |
Correct |
26 ms |
504 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
43 ms |
3704 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
43 ms |
3704 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
26 ms |
384 KB |
Output is correct |
2 |
Correct |
26 ms |
504 KB |
Output is correct |
3 |
Correct |
590 ms |
2320 KB |
Output is correct |
4 |
Correct |
605 ms |
2304 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
26 ms |
384 KB |
Output is correct |
2 |
Correct |
26 ms |
504 KB |
Output is correct |
3 |
Runtime error |
43 ms |
3704 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
4 |
Halted |
0 ms |
0 KB |
- |