Submission #338033

# Submission time Handle Problem Language Result Execution time Memory
338033 2020-12-22T09:44:31 Z nandonathaniel XOR Sum (info1cup17_xorsum) C++14
77 / 100
1421 ms 60348 KB
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const LL MAXN=1e6+5;
typedef pair<LL,LL> pii;

vector<pii> b,nol,satu;
LL a[MAXN];

int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	LL n,ans=0;
	cin >> n;
	for(LL i=1;i<=n;i++){
		cin >> a[i];
		b.push_back({0,i});
	}
	for(LL bt=0;bt<29;bt++){
		nol.clear();
		satu.clear();
		for(LL i=0;i<n;i++){
			if((1<<bt) & a[b[i].second]){
				satu.push_back({b[i].first+(1LL<<bt),b[i].second});
			}
			else{
				nol.push_back(b[i]);
			}
		}
		b.clear();
		for(auto isi : nol)b.push_back(isi);
		for(auto isi : satu)b.push_back(isi);
		LL notkel2=n-1,notkel3=n-1,notkel4=n-1,cnt=0;
		//binser TLE, terpaksa two poLLer
		for(auto isi : b){
			while(notkel2>=0 && isi.first+b[notkel2].first>=(1LL<<bt))notkel2--;
			while(notkel3>=0 && isi.first+b[notkel3].first>=2*(1LL<<bt))notkel3--;
			while(notkel4>=0 && isi.first+b[notkel4].first>=3*(1LL<<bt))notkel4--;
			cnt+=(n-1-notkel4+notkel3-notkel2);
		}
		for(auto isi : b){
			if((2*isi.first) & (1LL<<bt))cnt++;
		}
		cnt/=2;
		if(cnt&1)ans+=(1LL<<bt);
	}
	cout << ans << '\n';
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 640 KB Output is correct
2 Correct 5 ms 620 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1020 ms 60152 KB Output is correct
2 Correct 938 ms 57788 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1020 ms 60152 KB Output is correct
2 Correct 938 ms 57788 KB Output is correct
3 Correct 1172 ms 60220 KB Output is correct
4 Correct 1121 ms 58940 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 640 KB Output is correct
2 Correct 5 ms 620 KB Output is correct
3 Correct 107 ms 7012 KB Output is correct
4 Correct 109 ms 7020 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 640 KB Output is correct
2 Correct 5 ms 620 KB Output is correct
3 Correct 1020 ms 60152 KB Output is correct
4 Correct 938 ms 57788 KB Output is correct
5 Correct 1172 ms 60220 KB Output is correct
6 Correct 1121 ms 58940 KB Output is correct
7 Correct 107 ms 7012 KB Output is correct
8 Correct 109 ms 7020 KB Output is correct
9 Correct 1415 ms 60220 KB Output is correct
10 Correct 1417 ms 60220 KB Output is correct
11 Incorrect 1421 ms 60348 KB Output isn't correct