# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1146479 | Bilal_Coder | XOR Sum (info1cup17_xorsum) | C++20 | 1697 ms | 62964 KiB |
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx,avx2,fma")
using ll = long long;
template<typename... T>
void see(T&... args) { ((cin >> args), ...);}
#define seea(a , x , y) for(int i = x; i < y; i++){cin >> a[i];}
#define sees(s , n) for(int i = 0;i < n; i++){int x; cin >> x; s.insert(x);}
#define seev(v , n) for(int i = 0;i < n; i++){int x; cin >> x; v.push_back(x);}
#define ub(a, x) upper_bound(all(a), x)
#define lb(a, x) lower_bound(all(a), x)
#define rall(x) x.rbegin(), x.rend()
#define all(x) x.begin(), x.end()
#define pii pair<int , int>
#define sz(x) (int)x.size()
#define pq priority_queue
#define vec vector
#define arr array
#define int ll
const ll inf = 1e18;
const int N = 2e5 + 5;
void setIO(string s) {
freopen((s + ".in").c_str(), "r", stdin);
freopen((s + ".out").c_str(), "w", stdout);
}
void ssolve(vec<int> a , int mx){
int n = sz(a);
multiset<int> st(all(a));
int ans = 0 , mn = *st.begin();
for (int i = mn; i <= mx; i++){
for (int j = mn ; j + i <= mx << 1; j++){
int c1 = st.count(i) , c2 = st.count(j);
if (c1 & 1 && c2 & 1){
ans ^= (i + j);
}
}
}
cout << ans << "\n";
exit(0);
}
void solve() {
// Code here
int n;
see(n);
vec<int> a;
int mx = -inf;
for (int i = 0; i < n; i++){
int x;see(x);
mx = max(mx , x) , a.push_back(x);
}
if (mx <= 4000)
ssolve(a , mx);
int ans = 0;
for (int i = 0; i < n; i++){
for (int j = i; j < n; j++)
ans ^= (a[i] + a[j]);
}
cout << ans << "\n";
return;
}
int32_t main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
// setIO("");
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... |