Submission #358929

# Submission time Handle Problem Language Result Execution time Memory
358929 2021-01-26T07:34:40 Z ogibogi2004 XOR Sum (info1cup17_xorsum) C++14
39 / 100
1224 ms 70892 KB
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const ll MAXN=4e6+6;
const ll logN=22;
ll n,ans;
ll a[MAXN];
ll pref[2][MAXN];
int main()
{
	cin>>n;
	for(ll i=1;i<=n;i++)
	{
		cin>>a[i];
	}
	if(n<=4000)
	{
		for(ll i=1;i<=n;i++)
		{
			for(int j=i;j<=n;j++)
			{
				ans^=(a[i]+a[j]);
			}
		}
		cout<<ans<<endl;
		return 0;
	}
	for(ll j=0;j<logN;j++)
	{
		//cout<<j<<endl;
		memset(pref,0,sizeof(pref));
		for(ll i=1;i<=n;i++)
		{
			if(a[i]&(1<<j))
			{
				pref[1][a[i]%(1<<j)]++;
			}
			else
			{
				pref[0][a[i]%(1<<j)]++;
			}
		}
		for(ll j=1;j<MAXN;j++)
		{
			pref[0][j]+=pref[0][j-1];
			pref[1][j]+=pref[1][j-1];
		}
		ll cnt=0;
		for(ll i=1;i<=n;i++)
		{
			ll t=a[i]%(1<<j);
			if(a[i]&(1<<j))
			{
				if((1<<j)-t-1>=0)cnt+=pref[0][(1<<j)-t-1];
				cnt+=pref[1][MAXN-1]-pref[1][(1<<j)-t-1];
			}
			else
			{
				if((1<<j)-t-1>=0)cnt+=pref[1][(1<<j)-t-1];
				cnt+=pref[0][MAXN-1]-pref[0][(1<<j)-t-1];
			}
			if((a[i]*2)&(1<<j))cnt++;
		}
		//cout<<j<<" "<<cnt<<endl;
		if((cnt/2)%2==1)ans+=(1<<j);
	}
	cout<<ans<<endl;
return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 6 ms 364 KB Output is correct
2 Correct 6 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1014 ms 70892 KB Output is correct
2 Correct 1002 ms 70292 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1014 ms 70892 KB Output is correct
2 Correct 1002 ms 70292 KB Output is correct
3 Correct 1224 ms 70764 KB Output is correct
4 Correct 1195 ms 70552 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 364 KB Output is correct
2 Correct 6 ms 364 KB Output is correct
3 Incorrect 550 ms 64748 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 6 ms 364 KB Output is correct
2 Correct 6 ms 364 KB Output is correct
3 Correct 1014 ms 70892 KB Output is correct
4 Correct 1002 ms 70292 KB Output is correct
5 Correct 1224 ms 70764 KB Output is correct
6 Correct 1195 ms 70552 KB Output is correct
7 Incorrect 550 ms 64748 KB Output isn't correct
8 Halted 0 ms 0 KB -