Submission #999498

#TimeUsernameProblemLanguageResultExecution timeMemory
999498LOLOLOXOR Sum (info1cup17_xorsum)C++17
45 / 100
1622 ms9672 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define f first #define s second #define pb push_back #define ep emplace #define eb emplace_back #define lb lower_bound #define ub upper_bound #define all(x) x.begin(), x.end() #define rall(x) x.rbegin(), x.rend() #define uniquev(v) sort(all(v)), (v).resize(unique(all(v)) - (v).begin()) #define mem(f,x) memset(f , x , sizeof(f)) #define sz(x) (ll)(x).size() #define __lcm(a, b) (1ll * ((a) / __gcd((a), (b))) * (b)) #define mxx *max_element #define mnn *min_element #define cntbit(x) __builtin_popcountll(x) #define len(x) (int)(x.length()) const int N = 1e6 + 10; int a[N], n; vector <int> v; ll cal(int t) { ll ans = 0; for (int i = 0; i < sz(v); i++) { int p = lower_bound(all(v), t - v[i]) - v.begin(); ans += max(0, i - p + 1); } return ans; } int is(int j) { ll t = cal((1 << (j + 1)) | ((1 << j))) + cal((1 << (j + 1))) - cal(1 << j); return t % 2; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n; for (int i = 1; i <= n; i++) { cin >> a[i]; } int ans = 0; for (int j = 0; j < 30; j++) { v.clear(); for (int i = 1; i <= n; i++) { v.pb(a[i] % (1 << ((j + 1)))); } sort(all(v)); if (is(j)) ans |= (1 << j); } cout << ans << '\n'; return 0; } /* 011 011 */
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...