Submission #358910

# Submission time Handle Problem Language Result Execution time Memory
358910 2021-01-26T07:18:49 Z ogibogi2004 XOR Sum (info1cup17_xorsum) C++14
0 / 100
918 ms 35564 KB
#include<bits/stdc++.h>
using namespace std;
const int MAXN=4e6+6;
const int logN=21;
int n,ans;
int a[MAXN];
int pref[2][MAXN];
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
	}
	for(int j=0;j<logN;j++)
	{
		//cout<<j<<endl;
		memset(pref,0,sizeof(pref));
		for(int i=1;i<=n;i++)
		{
			if(a[i]&(1<<j))
			{
				pref[1][a[i]%(1<<j)]++;
			}
			else
			{
				pref[0][a[i]%(1<<j)]++;
			}
		}
		for(int j=1;j<MAXN;j++)
		{
			pref[0][j]+=pref[0][j-1];
			pref[1][j]+=pref[1][j-1];
		}
		int cnt=0;
		for(int i=1;i<=n;i++)
		{
			int 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++;
		}
		if((cnt/2)%2==1)ans+=(1<<j);
	}
	cout<<ans<<endl;
return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 358 ms 31724 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 918 ms 35564 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 918 ms 35564 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 358 ms 31724 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 358 ms 31724 KB Output isn't correct
2 Halted 0 ms 0 KB -