Submission #48395

# Submission time Handle Problem Language Result Execution time Memory
48395 2018-05-12T17:15:04 Z Pajaraja XOR Sum (info1cup17_xorsum) C++17
0 / 100
2 ms 548 KB
#include <bits/stdc++.h>
using namespace std;
int a[1000007],c[1000007];

int main()
{
	int n,sol=0;
	freopen("tc.txt","r",stdin);
	freopen("out.txt","w",stdout);
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	for(int j=0;j<30;j++)
	{
		int b=(1<<j),bc=0;
		for(int i=1;i<=n;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); 
		sort(c+1,c+n+1);
		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:8:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
  freopen("tc.txt","r",stdin);
  ~~~~~~~^~~~~~~~~~~~~~~~~~~~
xorsum.cpp:9:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
  freopen("out.txt","w",stdout);
  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
xorsum.cpp:10:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d",&n);
  ~~~~~^~~~~~~~~
xorsum.cpp:11: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 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 548 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 548 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -