답안 #389232

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
389232 2021-04-14T01:25:45 Z abc864197532 XOR Sum (info1cup17_xorsum) C++17
0 / 100
1600 ms 4172 KB
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define test(x) cout << #x << ' ' << x << endl
#define printv(x) { \
    for (auto a : x) cout << a << ' '; \
    cout << endl; \
}
#define pii pair<int, int>
#define pll pair<lli, lli>
#define X first
#define Y second
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
const int N = 200000, abc = 864197532;

int main () {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector <int> a(n);
    for (int i = 0; i < n; ++i) cin >> a[i];
    sort(all(a));
    int ans = 0;
    for (int k = 29; ~k; --k) {
        for (int i = 0; i < n; ++i) if (a[i] >= (1 << k + 1)) a[i] -= (1 << k + 1);
        sort(all(a));
        int cnt = 0;
        for (int i = 0; i < n; ++i) {
            int r = lower_bound(all(a), (1 << k + 1) - a[i]) - a.begin();
            int l = lower_bound(all(a), (1 << k) - a[i]) - a.begin();
            cnt ^= (r - l) & 1;
        }
        if (cnt) ans |= 1 << k;
        /*
         * 1. 2^k - a <= b < 2^{k + 1} - a
         * 0 3 5 8
         */
    }
    cout << ans << endl;
}

Compilation message

xorsum.cpp: In function 'int main()':
xorsum.cpp:30:57: warning: suggest parentheses around '+' inside '<<' [-Wparentheses]
   30 |         for (int i = 0; i < n; ++i) if (a[i] >= (1 << k + 1)) a[i] -= (1 << k + 1);
      |                                                       ~~^~~
xorsum.cpp:30:79: warning: suggest parentheses around '+' inside '<<' [-Wparentheses]
   30 |         for (int i = 0; i < n; ++i) if (a[i] >= (1 << k + 1)) a[i] -= (1 << k + 1);
      |                                                                             ~~^~~
xorsum.cpp:34:49: warning: suggest parentheses around '+' inside '<<' [-Wparentheses]
   34 |             int r = lower_bound(all(a), (1 << k + 1) - a[i]) - a.begin();
      |                                               ~~^~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 13 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1688 ms 4172 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1688 ms 4172 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 13 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 13 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -