Submission #999506

#TimeUsernameProblemLanguageResultExecution timeMemory
999506LOLOLOXOR Sum (info1cup17_xorsum)C++14
56 / 100
1643 ms8136 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, v[N]; ll cal(int t) { ll ans = 0; int p = n; for (int i = 1; i <= n; i++) { while (p - 1 >= 1 && v[i] + v[p - 1] >= t) p--; if (v[i] + v[p] >= t) 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++) { for (int i = 1; i <= n; i++) { v[i] = (a[i] % (1 << ((j + 1)))); } sort(v + 1, v + 1 + n); 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...