Submission #81683

# Submission time Handle Problem Language Result Execution time Memory
81683 2018-10-26T07:23:52 Z farukkastamonuda XOR Sum (info1cup17_xorsum) C++14
7 / 100
531 ms 13096 KB
#include <bits/stdc++.h>
#define fi first
#define se second
#define lo long long 
#define inf 1000000000
#define md 1000000007
#define li 1000005
#define mp make_pair
#define pb push_back
#define pi pair<lo int, int>
using namespace std;
int n,A[li],c[li],t,gg,sum;
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&A[i]);
	for(int i=0;i<=30;i++){
		int b=(1<<i);
		t=0;
		gg=0;
		if(i){
			for(int j=1;j<=n;j++){
				if((A[j]|(1<<(i-1)))!=A[j]) c[++t]=A[j];
			}
		}
		if(i){
			for(int j=1;j<=n;j++){
				if((A[j]|(1<<(i-1)))==A[j]) c[++t]=A[j];
			}
		}
		if(i){
			for(int j=1;j<=n;j++){
				A[j]=c[j];
				c[j]%=b;
			}
		}
		for(int j=1;j<=n;j++){
			if((A[j]|b)==A[j]) gg++;
		}
		int t1=1,t2=n,k=0;
		while(t1<=n){
			while(c[t1]+c[t2]>=b) {t2--;}	
			k+=n-t2;
			t1++;
		}
		for(int j=1;j<=n;j++){
			if(c[j]*2>=b) k++;
		}
		if((k/2+gg*(n-gg))%2==1) sum+=b;
	}
	printf("%d\n",sum);
	return 0;
}

Compilation message

xorsum.cpp: In function 'int main()':
xorsum.cpp:14:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d",&n);
  ~~~~~^~~~~~~~~
xorsum.cpp:15: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 Correct 6 ms 376 KB Output is correct
2 Correct 6 ms 672 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 531 ms 13096 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 531 ms 13096 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 6 ms 376 KB Output is correct
2 Correct 6 ms 672 KB Output is correct
3 Incorrect 91 ms 13096 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 6 ms 376 KB Output is correct
2 Correct 6 ms 672 KB Output is correct
3 Incorrect 531 ms 13096 KB Output isn't correct
4 Halted 0 ms 0 KB -