# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
128638 | 2019-07-11T07:51:41 Z | E869120 | XOR Sum (info1cup17_xorsum) | C++14 | 1600 ms | 20548 KB |
#include <iostream> #include <vector> #include <algorithm> using namespace std; #pragma warning (disable: 4996) int N, A[1 << 20]; int solve(int bit) { vector<int> vec; long long sum = 0; for (int i = 1; i <= N; i++) { vec.push_back(A[i] % (2 << bit)); vec.push_back((A[i] % (2 << bit)) + (2 << bit)); } sort(vec.begin(), vec.end()); for (int i = 1; i <= N; i++) { int F = (3 << bit) - (A[i] % (2 << bit)); F %= (2 << bit); int pos1 = lower_bound(vec.begin(), vec.end(), F) - vec.begin(); int pos2 = lower_bound(vec.begin(), vec.end(), F + (1 << bit)) - vec.begin(); sum += 1LL * (pos2 - pos1); } long long sum2 = 0; for (int i = 1; i <= N; i++) { if ((A[i] + A[i]) % (2 << bit) >= (1 << bit)) sum2++; } return (sum2 + (sum - sum2) / 2LL) % 2LL; } int main() { scanf("%d", &N); int maxn = 0; for (int i = 1; i <= N; i++) { scanf("%d", &A[i]); maxn = max(maxn, A[i]); } int P = 0; for (int i = 0; i <= 30; i++) { if ((1 << i) <= maxn) P = i; } int ans = 0; for (int i = 0; i <= P + 1; i++) { int t = solve(i); if (t == 1) ans += (1 << i); } printf("%d\n", ans); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 39 ms | 480 KB | Output is correct |
2 | Correct | 38 ms | 376 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1660 ms | 20548 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1660 ms | 20548 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 39 ms | 480 KB | Output is correct |
2 | Correct | 38 ms | 376 KB | Output is correct |
3 | Correct | 1313 ms | 2772 KB | Output is correct |
4 | Correct | 1310 ms | 2796 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 39 ms | 480 KB | Output is correct |
2 | Correct | 38 ms | 376 KB | Output is correct |
3 | Execution timed out | 1660 ms | 20548 KB | Time limit exceeded |
4 | Halted | 0 ms | 0 KB | - |