제출 #348957

#제출 시각아이디문제언어결과실행 시간메모리
348957ali_tavakoliXOR Sum (info1cup17_xorsum)C++14
45 / 100
1679 ms4332 KiB
//In The Name Of Allah
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
#define pb push_back
#define F first
#define S second
#pragma GCC optimize("Ofast")

const int maxn = 1e6 + 5, mxn = 1e6 + 5;

int n, a[maxn], cnt[maxn];

void sub1()
{
	int ans = 0;
	for(int i = 0; i < n; i++)
		for(int j = i; j < n; j++)
			ans ^= (a[i] + a[j]);
	cout << ans << '\n';
}

void sub2()
{
	int ans = 0;
	for(int i = 0; i < n; i++)
		cnt[a[i]] ++;
	for(int i = 0; i < mxn; i++)
		for(int j = i + 1; j < mxn; j++)
			if((cnt[i] * cnt[j]) % 2)
				ans ^= (i + j);
	//cout << ans << '\n';
	for(int i = 0; i < mxn; i++)
		if((cnt[i] * (cnt[i] - 1) / 2 + cnt[i]) % 2)
			ans ^= (i + i);
	cout << ans << '\n';
}

int main()
{
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	//auto t = clock();
	cin >> n;
	for(int i = 0; i < n; i++)
		cin >> a[i];
	
	if(n <= (1e5))
		sub1();
	else
		sub2();
}
#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...