Submission #48546

# Submission time Handle Problem Language Result Execution time Memory
48546 2018-05-15T22:36:20 Z Pajaraja XOR Sum (info1cup17_xorsum) C++17
0 / 100
556 ms 16852 KB
#include <bits/stdc++.h>
using namespace std;
int a[1000007],c[1000007];
int main()
{
	int n,sol=0;
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	for(int j=0;j<=31;j++)
	{
		int b=(1<<j),bc=0,t=0;
		if(j) for(int i=1;i<=n;i++) if((a[i] | (1<<(j-1)))!=a[i]) c[++t]=a[i];
		if(j) for(int i=1;i<=n;i++) if((a[i] | (1<<(j-1)))==a[i]) c[++t]=a[i];
		if(j) for(int i=1;i<=n;i++) {a[i]=c[i]; c[i]=a[i]%b;} 
		for(int i=1;i<=n;i++) if((a[i] | b) == a[i]) bc++;
		long long k=2*bc*(n-bc);
		int t1=1,t2=n;
		while(t1<=n)
		{
			while(c[t2]+c[t1]>=b) t2--;
			k+=(n-t2);
			t1++;
		}
		for(int i=1;i<=n;i++) if(2*c[i]>=b) k++;
		if((k/2)%2==1) sol+=b;
	}
	printf("%d",sol);
}

Compilation message

xorsum.cpp: In function 'int main()':
xorsum.cpp:7:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d",&n);
  ~~~~~^~~~~~~~~
xorsum.cpp:8:29: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(int i=1;i<=n;i++) scanf("%d",&a[i]);
                        ~~~~~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Runtime error 6 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 556 ms 16852 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 556 ms 16852 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 6 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 6 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -