Submission #98079

# Submission time Handle Problem Language Result Execution time Memory
98079 2019-02-20T14:13:57 Z Vasiljko XOR Sum (info1cup17_xorsum) C++14
7 / 100
131 ms 4256 KB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
const ll MOD = 1e9+7;
const int N = 1e6+5;

int n,a[N],mx;
int cnt[N];

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        mx=max(mx,a[i]);
    }

    if(n<=4000){
        int sum=0;
        for(int i=1;i<=n;i++){
            for(int j=i;j<=n;j++){
                sum^=(a[i]+a[j]);
            }
        }
        cout<<sum;
    }else if(mx<=4000){
        int sum=0;
        for(int i=1;i<=n;i++)cnt[a[i]]++;

        for(int i=1;i<=4000;i++){
            for(int j=i+1;j<=4000;j++){
                int c=cnt[i]*cnt[j];
                if(c%2==1)sum^=(i+j);
            }
        }
        for(int i=1;i<=4000;i++){
            int c=cnt[i]*(cnt[i]-1)/2+cnt[i];
            if(c==1)sum^=(2*i);
        }

        cout<<sum;
    }

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 8 ms 384 KB Output is correct
2 Correct 8 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 131 ms 4256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 131 ms 4256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 8 ms 384 KB Output is correct
2 Correct 8 ms 384 KB Output is correct
3 Incorrect 23 ms 740 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 8 ms 384 KB Output is correct
2 Correct 8 ms 384 KB Output is correct
3 Incorrect 131 ms 4256 KB Output isn't correct
4 Halted 0 ms 0 KB -