Submission #498781

# Submission time Handle Problem Language Result Execution time Memory
498781 2021-12-26T10:37:26 Z ahmedfouadnew XOR Sum (info1cup17_xorsum) C++17
0 / 100
1600 ms 117940 KB
#include<bits/stdc++.h>
using namespace std;
//#define int long long
#define pb push_back
int n;
vector<int>a[33];
signed main()
{
    scanf("%d",&n);
    int cnto=0,cnte=0;
    for(int i=0;i<n;i++)
    {
        int x;
        scanf("%d",&x);
        cnto+=(x%2);
        cnte+=(x%2==0);
        int cur=0;
        for(int j=0;j<30;j++)
        {
            cur+=x&(1<<j);
            a[j].pb(cur);
        }
    }
    for(int i=0;i<30;i++) sort(a[i].begin(),a[i].end());
    int ans=0;
    for(int i=0;i<30;i++)
    {
        int cur=0;
        for(int j=0;j<n;j++)
        {
            cur+=n-(lower_bound(a[i].begin(),a[i].end(),(1<<(i+1))-a[i][j])-a[i].begin());
        }
        ans+=(cur&1)*(1<<(i+1));
    }
    ans|=(1ll*cnto*cnte)&1ll;
    cout<<ans<<endl;
}

Compilation message

xorsum.cpp: In function 'int main()':
xorsum.cpp:9:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    9 |     scanf("%d",&n);
      |     ~~~~~^~~~~~~~~
xorsum.cpp:14:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |         scanf("%d",&x);
      |         ~~~~~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 10 ms 716 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1685 ms 117940 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1685 ms 117940 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 10 ms 716 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 10 ms 716 KB Output isn't correct
2 Halted 0 ms 0 KB -