# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1095414 | rahidilbayramli | XOR Sum (info1cup17_xorsum) | C++17 | 1671 ms | 65452 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.
#pragma GCC optimize("-O3")
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ld long double
#define vl vector<ll>
#define vi vector<int>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define pb push_back
#define p_b pop_back
#define pii pair<int, int>
#define pll pair<ll, ll>
#define f first
#define s second
using namespace std;
using namespace __gnu_pbds;
typedef tree<ll, null_type, less_equal<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
//random_device rd;
//mt19937 gen(rd());
//uniform_int_distribution<> d(0, 1e9);
void solve()
{
ll n, i, j;
cin >> n;
ll a[n+5];
for(i = 1; i <= n; i++)
cin >> a[i];
if(n <= 100000)
{
ll xorr = 0;
for(i = 1; i <= n; i++)
{
for(j = i; j <= n; j++)
xorr ^= (a[i] + a[j]);
}
cout << xorr << "\n";
}
else
{
map<ll, ll>mp;
for(i = 1; i <= n; i++)
mp[a[i]]++;
vector<pll>vect;
for(auto u : mp)
vect.pb(u);
ll xorr = 0;
for(i = 0; i < vect.size(); i++)
{
ll cnt = (vect[i].s * (vect[i].s + 1)) / 2;
if(cnt % 2 == 1)
xorr ^= (vect[i].f * 2);
for(j = i + 1; j < vect.size(); j++)
{
ll f = (vect[i].f + vect[j].f);
ll cnt = (vect[i].s * vect[j].s);
if(cnt % 2)
xorr ^= f;
}
}
cout << xorr << "\n";
}
}
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
ll tests = 1;
//cin >> tests;
while(tests--)
{
solve();
}
}
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... |