제출 #1148294

#제출 시각아이디문제언어결과실행 시간메모리
1148294weakweakweakXOR Sum (info1cup17_xorsum)C++20
56 / 100
553 ms51364 KiB
#include <bits/stdc++.h> using namespace std; int n, a[1888888], B = 30; vector<int> v[31]; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cin >> n; if (n > 100000) B = 12; for (int i = 1; i <= n; i++) { cin >> a[i]; for (int j = 0; j < B; j++) { v[j].push_back(a[i]%(1<<(j+1))); } } int ans = 0; for (int b = 0; b < B; b++) { sort(v[b].begin(), v[b].end()); long long cnt = 0; for (int i = 0, j=n, j2=n, j3=n; i < n; i++) { while (j > 0 and v[b][i] + v[b][j-1] >= (1<<b)) j--; while (j2 > 0 and v[b][i] + v[b][j2-1] >= (1<<(b+1))) j2--; while (j3 > 0 and v[b][i] + v[b][j3-1] >= (1<<b)+(1<<(b+1))) j3--; int a1 = n - j, a2 = n - j2, a3 = n - j3; cnt += (a1-a2); cnt += (a3); } for (int i = 1; i <= n; i++) if ((a[i]+a[i])&(1<<b)) cnt++; cnt /= 2; if (cnt & 1) ans += (1<<b); } cout << ans << '\n'; }
#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...