Submission #359144

# Submission time Handle Problem Language Result Execution time Memory
359144 2021-01-26T11:39:21 Z ogibogi2004 XOR Sum (info1cup17_xorsum) C++14
Compilation error
0 ms 0 KB
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int MAXN=1e6+6;
const int logN=30;
int n;
int a[MAXN],a1[MAXN];
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n;
	for(int i=1;i<=n;++i)
	{
		cin>>a[i];
	}
	int ans=0;
	for(int j=0;j<logN;++j)
	{
		sz=0;
		if(j!=0)
		{
			for(int i=1;i<=n;++i)
			{
				if(!(a[i]&(1<<(j-1))))
				{
					a1[++sz]=a[i];
				}
			}
			for(int i=1;i<=n;++i)
			{
				if(a[i]&(1<<(j-1)))
				{
					a1[++sz]=a[i];
				}
			}
			for(int i=1;i<=n;++i)a[i]=a1[i];
		}
		ll cnt0up=0,cnt1up=0,cnt0down=0,cnt1down=0;
		int p=n;
		ll cnt=0;
		for(int i=1;i<=n;++i)
		{
			if(a[i]&(1<<j))++cnt1up;
			else ++cnt0up;
		}
		for(int i=1;i<=n;++i)
		{
			while(p>0&&a[p]%(1<<j)+a[i]%(1<<j)>=(1<<j))
			{
				if(a[p]&(1<<j))++cnt1down,--cnt1up;
				else ++cnt0down,--cnt0up;
				--p;
			}
			if(a[i]&(1<<j))
			{
				cnt+=cnt0up+cnt1down;
			}
			else
			{
				cnt+=cnt1up+cnt0down;
			}
			if((2*a[i])&(1<<j))++cnt;
		}
		//cout<<j<<" "<<cnt<<endl;
		if((cnt/2)%2==1)
		{
			ans+=(1<<j);
		}
	}
	cout<<ans<<"\n";
return 0;
}

Compilation message

xorsum.cpp: In function 'int main()':
xorsum.cpp:21:3: error: 'sz' was not declared in this scope
   21 |   sz=0;
      |   ^~