답안 #644797

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
644797 2022-09-25T08:57:43 Z notme XOR Sum (info1cup17_xorsum) C++14
18 / 100
137 ms 22572 KB
#include<bits/stdc++.h>
#define endl '\n'
using namespace std;
const int MAXN = 1e6 + 10;
void speed()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}

int n;
long long a[MAXN];
long long cnt[MAXN];
long long maxx = 0;
void read()
{
    cin >> n;
    for (int i = 1; i <= n; ++ i)
    {
        cin >> a[i];
        if(a[i] < 1e6 + 10)cnt[a[i]] ++;
        maxx = max(maxx, a[i]);
    }
}

void solve1()
{
    long long ans = 0;
    for (int i = 1; i <= n; ++ i)
    {
        for (int j = i; j <= n; ++ j)
        {
            ans = (ans ^ (a[i] + a[j]));
        }
    }
    cout << ans << endl;
}

void solve2()
{
    long long ans = 0;
    for (int i = 1; i <= 4*1e3; ++ i)
    {
        for (int j = i+1; j <= 4*1e3; ++ j)
        {
            long long times = cnt[i] * cnt[j];
            long long used = times;
            //if(times != 0)cout << i << " " << j << " " << times << endl;
            if(used & 1)ans = (ans ^ (i + j));
        }
    }
    for (int i = 1; i <= 4*1e3; ++ i)
    {
        int times = ((cnt[i] * (cnt[i]-1))/2) + cnt[i];
        if(times & 1)ans = ans ^ (i*2);
    }
    cout << ans << endl;
}
int main()
{
    speed();

    read();
    if(n <= 4 * 1e3)solve1();
    else if(maxx <= 4 * 1e3)solve2();
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 468 KB Output is correct
2 Correct 5 ms 560 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 76 ms 8256 KB Output is correct
2 Correct 77 ms 11920 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 76 ms 8256 KB Output is correct
2 Correct 77 ms 11920 KB Output is correct
3 Incorrect 137 ms 22572 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 468 KB Output is correct
2 Correct 5 ms 560 KB Output is correct
3 Incorrect 11 ms 3924 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 468 KB Output is correct
2 Correct 5 ms 560 KB Output is correct
3 Correct 76 ms 8256 KB Output is correct
4 Correct 77 ms 11920 KB Output is correct
5 Incorrect 137 ms 22572 KB Output isn't correct
6 Halted 0 ms 0 KB -