Submission #1314189

#TimeUsernameProblemLanguageResultExecution timeMemory
1314189Ekber_EkberXOR Sum (info1cup17_xorsum)C++20
7 / 100
1695 ms8256 KiB
#include <bits/stdc++.h>
#define GOOD_LUCK ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long
#define endl "\n"
#define ff first
#define ss second
#define pb push_back
#define all(v) v.begin(), v.end()
using namespace std;

constexpr int MAX = 2e+5 + 1, INF = 2e+9, MOD = 1e+9 + 7, K = 29;

void _() {
	int n;
	cin >> n;
	vector <int> v(n);
	for (int &i : v) cin >> i;
	int res=0;
	for (int i = K; i >= 0; i--) {
		vector <int> x = v;
		int m = (1LL << (i + 1));
		for (int &j : x) j %= m;
		sort(all(x));
		int c=0;
		while (!x.empty()) {
			int k = x.back();
			int mn = (1LL << i);
			int mx = (1LL << (i + 1)) - 1;
			mn -= k, mx -= k;
			if (mn <= mx) c += upper_bound(all(x), mx) - lower_bound(all(x), mn);
			mn = (1LL << i) * 3;
			mx = (1LL << (i + 2)) - 1;
			mn -= k, mx -= k;
			if (mn <= mx) c += upper_bound(all(x), mx) - lower_bound(all(x), mn);
			x.pop_back();
		}
		res += (1LL << i) * (c % 2);
	}
	cout << res;
}

signed main() {

	GOOD_LUCK

	int tests=1;
	// cin >> tests;
	for (int i=1; i <= tests; i++) {
		_();
		cout << endl;
	}

	return 0;
}
/*
0011
0110
0110
1001

001
011
110
110

100 -> min
111 -> max



*/
#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...