제출 #141162

#제출 시각아이디문제언어결과실행 시간메모리
141162meatrowXOR Sum (info1cup17_xorsum)C++17
7 / 100
1677 ms26116 KiB
//#pragma GCC optimize("O3") //#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native") //#pragma GCC optimize ("unroll-loops") #include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; const int M = 29; unordered_map<int, int> f; void add(int pos, int sz) { for (; pos < sz; pos |= pos + 1) { f[pos]++; } } int get(int pos) { int res = 0; for (; pos >= 0; pos = (pos & (pos + 1)) - 1) { res += f[pos]; } return res; } int get(int l, int r) { if (l > r) { return 0; } return get(r) - get(l - 1); } const int N = 1e6; int a[N]; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); int n; cin >> n; for (int i = 0; i < n; i++) { cin >> a[i]; } int ans = 0; int pw = 2; for (int b = 0; b < M; b++) { f.clear(); int kek = 0; for (int i = 0; i < n; i++) { int t = a[i] % pw; add(t, pw); if (a[i] & (1 << b)) { kek += get(0, pw - 1 - t) + get(pw - t + pw / 2, pw - 1); kek &= 1; } else { kek += get(pw / 2 - t, pw - 1 - t); kek &= 1; } } ans += kek * pw / 2; pw <<= 1; } cout << ans; return 0; }
#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...