# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
348951 | ali_tavakoli | XOR Sum (info1cup17_xorsum) | C++14 | 125 ms | 4332 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.
//In The Name Of Allah
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define F first
#define S second
#pragma GCC optimize("Ofast")
const int maxn = 1e6 + 5, mxn = 4e3 + 5;
int n, a[maxn], cnt[maxn];
void sub1()
{
ll ans = 0;
for(int i = 0; i < n; i++)
for(int j = i; j < n; j++)
ans ^= (a[i] + a[j]);
cout << ans << '\n';
}
void sub2()
{
ll ans = 0;
for(int i = 0; i < n; i++)
cnt[a[i]] ++;
for(int i = 0; i < mxn; i++)
for(int j = 0; j < mxn; j++)
if((cnt[i] * cnt[j]) % 2)
ans ^= (i + j);
cout << ans << '\n';
}
int main()
{
ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
auto t = clock();
cin >> n;
for(int i = 0; i < n; i++)
cin >> a[i];
if(n <= (4e3))
sub1();
else
sub2();
}
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... |