답안 #720349

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
720349 2023-04-08T04:34:36 Z GrandTiger1729 XOR Sum (info1cup17_xorsum) C++17
45 / 100
1600 ms 12768 KB
#include <bits/stdc++.h>
using namespace std;

const int N = 30;
int main(){
    cin.tie(0)->sync_with_stdio(0);
    int n; cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++)
        cin >> a[i];
    int ans = 0;
    for (int j = 0; j < N; j++){
        long long cnt = 0;
        for (int i = 0; i < n; i++){
            if (a[i] & 1 << j)
                cnt += n + 1;
        }
        ans ^= (cnt & 1) << j;
    }
    for (int j = 1; j <= N; j++){
        vector<int> b(n);
        transform(a.begin(), a.end(), b.begin(), [&](int x){
            return x % (1 << j);
        });
        sort(b.begin(), b.end());
        long long cnt = 0;
        for (int i = 0; i < n; i++){
            cnt += b.end() - lower_bound(b.begin(), b.end(), (1 << j) - b[i]);
            cnt += b[i] >= (1 << j - 1);
        }
        cnt /= 2;
        ans ^= (cnt & 1) << j;
    }
    cout << ans << '\n';
    return 0;
}

Compilation message

xorsum.cpp: In function 'int main()':
xorsum.cpp:29:36: warning: suggest parentheses around '-' inside '<<' [-Wparentheses]
   29 |             cnt += b[i] >= (1 << j - 1);
      |                                  ~~^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 340 KB Output is correct
2 Correct 12 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1658 ms 12768 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1658 ms 12768 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 340 KB Output is correct
2 Correct 12 ms 340 KB Output is correct
3 Correct 284 ms 1988 KB Output is correct
4 Correct 304 ms 1996 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 340 KB Output is correct
2 Correct 12 ms 340 KB Output is correct
3 Execution timed out 1658 ms 12768 KB Time limit exceeded
4 Halted 0 ms 0 KB -