# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
128633 | 2019-07-11T07:50:10 Z | E869120 | XOR Sum (info1cup17_xorsum) | C++14 | 1600 ms | 20408 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); for (int i = 1; i <= N; i++) scanf("%d", &A[i]); int ans = 0; for (int i = 0; i <= 29; i++) { int t = solve(i); if (t == 1) ans += (1 << i); } printf("%d\n", ans); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 38 ms | 376 KB | Output is correct |
2 | Correct | 38 ms | 376 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1681 ms | 20408 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1681 ms | 20408 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 38 ms | 376 KB | Output is correct |
2 | Correct | 38 ms | 376 KB | Output is correct |
3 | Correct | 1311 ms | 2736 KB | Output is correct |
4 | Correct | 1307 ms | 3656 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 38 ms | 376 KB | Output is correct |
2 | Correct | 38 ms | 376 KB | Output is correct |
3 | Execution timed out | 1681 ms | 20408 KB | Time limit exceeded |
4 | Halted | 0 ms | 0 KB | - |