Submission #498784

# Submission time Handle Problem Language Result Execution time Memory
498784 2021-12-26T10:41:53 Z ahmedfouadnew XOR Sum (info1cup17_xorsum) C++17
0 / 100
275 ms 131072 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("%lld",&n);
    long long cnto=0,cnte=0;
    for(int i=0;i<n;i++)
    {
        int x;
        scanf("%lld",&x);
        cnto+=(x%2);
        cnte+=(x%2==0);
        int cur=0;
        for(int j=0;j<30;j++)
        {
            cur+=x&(1ll<<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(),(1ll<<(i+1))-a[i][j])-a[i].begin());
        }
        ans|=(cur&1ll)*(1ll<<(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("%lld",&n);
      |     ~~~~~^~~~~~~~~~~
xorsum.cpp:14:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |         scanf("%lld",&x);
      |         ~~~~~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 10 ms 1228 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 275 ms 131072 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 275 ms 131072 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 10 ms 1228 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 10 ms 1228 KB Output isn't correct
2 Halted 0 ms 0 KB -