Submission #98080

# Submission time Handle Problem Language Result Execution time Memory
98080 2019-02-20T14:14:58 Z Vasiljko XOR Sum (info1cup17_xorsum) C++14
18 / 100
150 ms 7416 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%2==1)sum^=(2*i);
        }

        cout<<sum;
    }

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 11 ms 384 KB Output is correct
2 Correct 7 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 150 ms 4252 KB Output is correct
2 Correct 121 ms 7416 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 150 ms 4252 KB Output is correct
2 Correct 121 ms 7416 KB Output is correct
3 Incorrect 125 ms 7132 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 11 ms 384 KB Output is correct
2 Correct 7 ms 384 KB Output is correct
3 Incorrect 16 ms 804 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 11 ms 384 KB Output is correct
2 Correct 7 ms 384 KB Output is correct
3 Correct 150 ms 4252 KB Output is correct
4 Correct 121 ms 7416 KB Output is correct
5 Incorrect 125 ms 7132 KB Output isn't correct
6 Halted 0 ms 0 KB -