# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
67829 | ege_eksi | XOR Sum (info1cup17_xorsum) | C++14 | 1660 ms | 8516 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<algorithm>
using namespace std;
int *v;
int main()
{
int n;
scanf("%d",&n);
v = new int[n];
int x = 0;
for(int i = 0 ; i < n ; i++)
{
scanf("%d",&v[i]);
x = max(x , v[i]);
}
if(n < x){
long long int ans = 0;
int i , j;
for(i = 0 ; i < n ; i++)
{
for(j = i ; j < n ; j++)
{
ans = ans ^ (v[i] + v[j]);
}
}
printf("%lli",ans);
return 0;
}
if(x < n)
{
int cnt[4001] = {0};
int i , j;
for(i = 0 ; i < n ; i++)
{
cnt[v[i]]++;
}
/*
for(i = 1 ; i <= x ; i++)
{
printf("%d: %d\n",i , cnt[i]);
}
*/
long long int ans = 0;
for(i = 1 ; i <= x ; i++)
{
if(cnt[i] != 0)
{
if((cnt[i] + cnt[i] * (cnt[i]-1) / 2) % 2 != 0)
{
ans = ans ^ (i+i);
}
for(j = i+1 ; j <= x ; j++)
{
if(cnt[j] != 0)
{
if((cnt[i] * cnt[j]) % 2 != 0)
{
ans = ans ^ (i+j);
}
}
}
}
}
printf("%lli" , ans);
return 0;
}
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |