# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
389275 | 2021-04-14T02:07:25 Z | syl123456 | XOR Sum (info1cup17_xorsum) | C++17 | 314 ms | 8372 KB |
#include <bits/stdc++.h> #define all(i) (i).begin(), (i).end() #define debug(x) cerr << "Line(" << __LINE__ << ") -> " << #x << " is " << x << endl using namespace std; template<typename T1, typename T2> ostream& operator << (ostream &i, pair<T1, T2> j) { return i << j.first << ' ' << j.second; } template<typename T> ostream& operator << (ostream &i, vector<T> j) { i << '{' << j.size() << ':'; for (T ii : j) i << ' ' << ii; return i << '}'; } typedef long long ll; typedef pair<int, int> pi; typedef pair<pi, int> pp; int main() { ios::sync_with_stdio(0), cin.tie(0); int n; cin >> n; int a[n]; for (int &i : a) cin >> i; int ans = 0; for (int i = 0; i < 20; ++i) { int x = (1 << i + 1) - 1, cnt[x + 1]{}; ll tmp = 0; for (int j : a) ++cnt[j & x]; for (int j = 1; j < 1 << i; ++j) cnt[j] += cnt[j - 1]; for (int j = (1 << i) + 1; j < 1 << i + 1; ++j) cnt[j] += cnt[j - 1]; for (int j : a) { j &= x; if (j << 1 & 1 << i) ++tmp; if (j >> i & 1) { tmp += cnt[x - j]; tmp += cnt[x] - cnt[x + (1 << i) - j]; } else { tmp += cnt[x >> 1] - cnt[(x >> 1) - j]; tmp += cnt[x - j]; } } if (tmp & 2) ans ^= 1 << i; } cout << ans; } /* * * * * */
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 10 ms | 4556 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 255 ms | 8372 KB | Output is correct |
2 | Correct | 243 ms | 7920 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 255 ms | 8372 KB | Output is correct |
2 | Correct | 243 ms | 7920 KB | Output is correct |
3 | Correct | 314 ms | 8312 KB | Output is correct |
4 | Incorrect | 295 ms | 8128 KB | Output isn't correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 10 ms | 4556 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 10 ms | 4556 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |