# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
551132 | 2022-04-19T22:42:38 Z | Olympia | XOR Sum (info1cup17_xorsum) | C++17 | 1600 ms | 4180 KB |
#include <iostream> #include <vector> #include <iomanip> #include <algorithm> #include <cassert> #include <map> #include <complex> #include <cmath> #include <set> #include <queue> using namespace std; int64_t res (vector<int>& a, int x) { //how many are <= x int64_t r = a.size() - 1; int64_t ans = 0; for (int i = 0; i < a.size(); i++) { if (a[i] + a[0] > x) { break; } while (a[r] + a[i] > x) { r--; } ans += abs(r) + 1 - (r >= i); } ans /= 2; for (int i = 0; i < a.size(); i++) { ans += (2 * a[i] <= x); } return ans; } int64_t res (vector<int>& a, int l, int r) { return res(a, r) - res(a, l - 1); } int main () { ios_base::sync_with_stdio(false); cin.tie(NULL); int n; cin >> n; vector<int> v(n); for (int i = 0; i < n; i++) { cin >> v[i]; } int64_t ans = 0; for (int b = 30; b >= 0; b--) { for (int i = 0; i < v.size(); i++) { v[i] = v[i] & ((1 << (b + 1)) - 1); } sort(v.begin(), v.end()); int64_t r = 0; r += res(v, (1 << b), (1 << (b + 1)) - 1); r += res(v, (1 << b) + (1 << (b + 1)), (1 << (b + 2)) - 1); ans += ((int64_t)1 << b) * (r % 2); } cout << ans; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 7 ms | 212 KB | Output is correct |
2 | Correct | 8 ms | 212 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 893 ms | 4180 KB | Output is correct |
2 | Correct | 860 ms | 3924 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 893 ms | 4180 KB | Output is correct |
2 | Correct | 860 ms | 3924 KB | Output is correct |
3 | Correct | 1311 ms | 4180 KB | Output is correct |
4 | Correct | 1254 ms | 4052 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 7 ms | 212 KB | Output is correct |
2 | Correct | 8 ms | 212 KB | Output is correct |
3 | Correct | 185 ms | 724 KB | Output is correct |
4 | Correct | 200 ms | 596 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 7 ms | 212 KB | Output is correct |
2 | Correct | 8 ms | 212 KB | Output is correct |
3 | Correct | 893 ms | 4180 KB | Output is correct |
4 | Correct | 860 ms | 3924 KB | Output is correct |
5 | Correct | 1311 ms | 4180 KB | Output is correct |
6 | Correct | 1254 ms | 4052 KB | Output is correct |
7 | Correct | 185 ms | 724 KB | Output is correct |
8 | Correct | 200 ms | 596 KB | Output is correct |
9 | Execution timed out | 1686 ms | 4180 KB | Time limit exceeded |
10 | Halted | 0 ms | 0 KB | - |