| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1312794 | neonglitch | XOR Sum (info1cup17_xorsum) | C++20 | 1657 ms | 33972 KiB |
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
#define int ll
const int N=1e6+2;
int a[N],c[N],ord[N],n,pw=1;
int get(int R)
{
int i=0,ans=0;
// cout<<"We want "<<R<<endl;
// cout<<"Array ";
// for(int i=0;i<n;i++)cout<<a[ord[i]]%pw<<' ';
// cout<<endl;
while(i+1<n and (a[ord[i]]%pw)+(a[ord[0]]%pw)<R)
{
i++;
}
for(int j=0;j<n;j++)
{
while(i>=0 and (a[ord[i]]%pw)+(a[ord[j]]%pw)>=R)
{
i--;
}
// cout<<"two po "<<j<<' '<<i<<endl;
ans+=(i+1);
}
// cout<<"answer "<<ans<<endl;
// int cntp=0;
// for(int i=0;i<n;i++)
// {
// cout<<"For "<<i<<' ';
// for(int j=0;j<n;j++)
// {
// if((a[ord[i]]%pw)+(a[ord[j]]%pw) < R)
// {
// cout<<j<<' ';
// cntp++;
// }
// }
// cout<<endl;
// }
// cout<<"REAL "<<cntp<<endl;
return ans;
}
main()
{
// int t=1;
// cin>>t;
// while(t--)
{
cin>>n;
for(int i=0;i<n;i++)
{
cin>>a[i];
ord[i]=i;
}
int fnl=0;
for(int j=0;j<22;j++)
{
pw*=2;
vector<int> nxt[2]={};
for(int i=0;i<n;i++)
{
nxt[((a[ord[i]]>>j)&1)].push_back(ord[i]);
}
int lpt=0;
for(auto&x:nxt[0])ord[lpt++]=x;
for(auto&x:nxt[1])ord[lpt++]=x;
int on=get(pw)-get(pw/2);
on += get(2*pw)-get(pw+(pw/2));
for(int i=0;i<n;i++)
{
int x=(a[(ord[i])]%pw)*2;
if(x<pw and x>=(pw/2))
{
on++;
}
if(x<2*pw and x>=(pw+(pw/2)))
{
on++;
}
}
nxt[0].clear();
nxt[1].clear();
on/=2;
if(on&1)fnl+=pw/2;
}
cout<<fnl<<endl;
}
}
Compilation message (stderr)
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
