Submission #1139298

#TimeUsernameProblemLanguageResultExecution timeMemory
1139298JelalTkmXOR Sum (info1cup17_xorsum)C++20
18 / 100
109 ms8264 KiB
#include <bits/stdc++.h> #pragma GCC optimize ("O3") #pragma GCC target ("sse4") using namespace std; #define int long long int const int N = 4e3 + 100; const int md = 1e9 + 7; const int INF = 1e9; int32_t main(int32_t argc, char *argv[]) { ios::sync_with_stdio(false); cin.tie(nullptr); int T = 1; // cin >> T; while (T--) { int n; cin >> n; if (n <= 2e4) { vector<int> a(n); for (int i = 0; i < n; i++) cin >> a[i]; int ans = 0; for (int i = 0; i < n; i++) for (int j = i; j < n; j++) ans ^= (a[i] + a[j]); cout << ans << '\n'; } else { vector<int> a(n), cnt(N); for (int i = 0; i < n; i++) { cin >> a[i]; cnt[a[i]]++; } int ans = 0; for (int i = 1; i < N; i++) { for (int j = i + 1; j < N; j++) { if ((i != j && cnt[j] > 0 && cnt[i] > 0) || (i == j && cnt[i] >= 2)) { if (((cnt[j] - (i == j)) & 1) && ((cnt[i] - (i == j)) & 1)) { int x = i + j; for (int k = 0; k < 30; k++) if (((1 << k) & x)) { ans ^= (1 << k); } } } } cnt[i] = 0; } for (int i = 0; i < n; i++) { cnt[a[i]]++; } for (int i = 1; i < N; i++) if ((((cnt[i] * (cnt[i] - 1)) >> 1) + cnt[i]) & 1) ans ^= (i + i); cout << ans << '\n'; } } return 0; }
#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...