# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
886956 | 2023-12-13T09:03:33 Z | Zero_OP | XOR Sum (info1cup17_xorsum) | C++14 | 298 ms | 15328 KB |
#include<bits/stdc++.h> using namespace std; #define range(v) begin(v), end(v) #define compact(v) v.erase(unique(range(v)), end(v)) template<class T> bool minimize(T& a, T b){ if(a > b) return a = b, true; return false; } template<class T> bool maximize(T& a, T b){ if(a < b) return a = b, true; return false; } typedef long long ll; typedef unsigned long long ull; typedef long double ld; int n; vector<int> a; void radixSort(int b){ vector<int> lastZero, lastOne; for(int i = 0; i < n; ++i){ if(a[i] >> b & 1){ lastOne.push_back(a[i]); } else{ lastZero.push_back(a[i]); } } a = lastZero; a.insert(a.begin(), range(lastOne)); } void Zero_OP(){ cin >> n; a = vector<int>(n); for(int i = 0; i < n; ++i){ cin >> a[i]; } sort(range(a)); int ans = 0; for(int target = 30; target >= 0; --target){ //last target bits radixSort(target); ll cur = 0; int j = n, k = n, l = n; for(int i = 0; i < n; ++i){ maximize(j, i); maximize(k, i); maximize(l, i); while(i < j and a[i] + a[j - 1] >= (1 << target)) --j; while(i < k and a[i] + a[k - 1] > ((1 << (target + 1)) - 1)) --k; while(i < l and a[i] + a[l - 1] >= (1 << (target + 1)) + (1 << target)) --l; cur += k - j; cur += n - l; } if(cur & 1) ans ^= (1 << target); } cout << ans << '\n'; } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); #define task "antuvu" if(fopen(task".inp", "r")){ freopen(task".inp", "r", stdin); freopen(task".out", "w", stdout); } Zero_OP(); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 348 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 298 ms | 15328 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 298 ms | 15328 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 348 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 348 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |