답안 #916392

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
916392 2024-01-25T19:32:08 Z andrei_iorgulescu XOR Sum (info1cup17_xorsum) C++14
45 / 100
1600 ms 12308 KB
#include <bits/stdc++.h>

using namespace std;

int n,a[1000005],v[1000005],vmax;

int f(int x)
{
    int st = 0,pas = 1 << 19;
    while (pas != 0)
    {
        if (st + pas <= n and v[st + pas] < x)
            st += pas;
        pas >>= 1;
    }
    return st + 1;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin >> n;
    for (int i = 1; i <= n; i++)
    {
        cin >> a[i];
        vmax = max(vmax,a[i]);
    }
    int ans = 0;
    for (int b = 0; (1 << b) <= 2 * vmax; b++)
    {
        for (int i = 1; i <= n; i++)
            v[i] = a[i] & ((1 << (b + 1)) - 1);
        sort(v + 1,v + n + 1);
        int cate = 0;
        for (int i = 1; i <= n; i++)
        {
            if ((v[i] & (1 << b)) == 0)
            {
                ///v[j] >= 2^b - v[i] si v[j] < 2^(b+1) - v[i], in plus j <= i
                int l = f((1 << b) - v[i]),r = f((1 << (b + 1)) - v[i]) - 1;
                if (l <= i and (min(i,r) - l + 1) % 2 == 1)
                    cate ^= 1;
            }
            else
            {
                ///v[j] < 2^(b+1) - v[i] sau v[j] >= 3 * 2^b - v[i]
                int r1 = f((1 << (b + 1)) - v[i]) - 1,l2 = f(3 * (1 << b) - v[i]);
                if (r1 % 2 == 1)
                    cate ^= 1;
                if (l2 <= i and (i - l2 + 1) % 2 == 1)
                    cate ^= 1;
            }
        }
        if (cate == 1)
            ans += (1 << b);
    }
    cout << ans;
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 2396 KB Output is correct
2 Correct 11 ms 2572 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1619 ms 12308 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1619 ms 12308 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 2396 KB Output is correct
2 Correct 11 ms 2572 KB Output is correct
3 Correct 421 ms 7724 KB Output is correct
4 Correct 413 ms 7716 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 2396 KB Output is correct
2 Correct 11 ms 2572 KB Output is correct
3 Execution timed out 1619 ms 12308 KB Time limit exceeded
4 Halted 0 ms 0 KB -