Submission #128998

#TimeUsernameProblemLanguageResultExecution timeMemory
128998TAISA_XOR Sum (info1cup17_xorsum)C++14
7 / 100
109 ms8952 KiB
#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<int> co(4010); for (int i = 0; i < n; i++) { co[a[i]]++; } int x = 0; for (int i = 1; i <= 4000; i++) { if (co[i] == 0 || co[i] % 4 == 0 || (co[i] - 1) % 4 == 0) { continue; } x ^= 2 * i; 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; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...