Submission #98082

# Submission time Handle Problem Language Result Execution time Memory
98082 2019-02-20T14:17:29 Z Vasiljko XOR Sum (info1cup17_xorsum) C++14
18 / 100
132 ms 4280 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;
            if(c%2==1)sum^=(2*i);
        }
        for(int i=1;i<=4000;i++){
            if(cnt[i]%2==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 Correct 116 ms 4244 KB Output is correct
2 Correct 102 ms 4052 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 116 ms 4244 KB Output is correct
2 Correct 102 ms 4052 KB Output is correct
3 Incorrect 132 ms 4280 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 25 ms 768 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 Correct 116 ms 4244 KB Output is correct
4 Correct 102 ms 4052 KB Output is correct
5 Incorrect 132 ms 4280 KB Output isn't correct
6 Halted 0 ms 0 KB -