Submission #129001

# Submission time Handle Problem Language Result Execution time Memory
129001 2019-07-11T12:13:07 Z TAISA_ XOR Sum (info1cup17_xorsum) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll LINF = (1LL << 60) - 1LL;
constexpr double eps = 1e-9;
constexpr ll MOD = 1000000007LL;
template <typename T> bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
};
template <typename T> bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
};
template <typename T> ostream &operator<<(ostream &os, vector<T> v) {
    for (int i = 0; i < v.size(); i++) {
        os << v[i] << (i + 1 == v.size() ? "\n" : " ");
    }
    return os;
}
template <typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template <typename T, typename... Ts> auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type fill_v(T &t, const V &v) {
    t = v;
}
template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type fill_v(T &t, const V &v) {
    for (auto &e : t) {
        fill_v(e, v);
    }
};
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    int x = 0;
    if (n <= 4000) {
        for (int i = 0; i < n; i++) {
            for (int j = i; j < n; j++) {
                x ^= (a[i] + a[j]);
            }
        }
    } else {
        vector<ll> co(4010);
        for (int i = 0; i < n; i++) {
            co[a[i]]++;
        }
        for (int i = 1; i <= 4000; i++) {
            if (co[i] == 0) {
                continue;
            }
            ll s = (co[i] - 1LL) * co[i] / 2LL + co[i];
            if (s % 2) {
                x ^= (i + j);
            }
            for (int j = i + 1; j <= 4000; j++) {
                if (co[j] == 0 || co[i] % 2 == 0 || co[j] % 2 == 0) {
                    continue;
                }
                x ^= (i + j);
            }
        }
    }
    cout << x << endl;
}

Compilation message

xorsum.cpp: In function 'int main()':
xorsum.cpp:71:27: error: 'j' was not declared in this scope
                 x ^= (i + j);
                           ^