Submission #496733

#TimeUsernameProblemLanguageResultExecution timeMemory
496733IerusXOR Sum (info1cup17_xorsum)C++17
18 / 100
299 ms16340 KiB
#include<bits/stdc++.h> using namespace std; #pragma GCC optimize ("unroll-loops,Ofast,O3") #pragma GCC target("avx,avx2,fma") #define F first #define S second #define int long long #define sz(x) (int)x.size() #define pb push_back #define eb emplace_back #define all(x) (x).begin(),(x).end() #define rall(x) (x).rbegin(),(x).rend() #define NFS ios_base::sync_with_stdio(0) , cin.tie(0) , cout.tie(0) ; #define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout) const int E = (int)1e6+777; const int N = (int)4e3+12; int n, a[E]; void solve1(int res = 0){ for(int i = 1; i <= n; ++i){ for(int j = i; j <= n; ++j){ res ^= (a[i] + a[j]); } } cout << res; exit(false); } void solve2(int res = 0){ vector<int> cnt(N, 0), s(N+N+2,0); for(int i = 1; i <= n; ++i){ ++cnt[a[i]]; } for(int i = 1; i <= N; ++i){ for(int j = i; j <= N; ++j){ if(i == j && cnt[i]){ // cerr << "i: " << i << " cnt[i]: " << cnt[i] << '\n'; s[i+j] += cnt[i] * (cnt[i] + 1) / 2; }else if(cnt[i] & cnt[j]){ // cerr << "i: " << i << " cnt[i]: " << cnt[i] << " j: " << j << " cnt[j]: " << j << '\n'; s[i+j] += cnt[i] * cnt[j]; } } } for(int i = 1; i <= (int)8e3; ++i){ if(s[i] & 1){ // cerr << "i: " << i << " sm[i]: " << s[i] << '\n'; res ^= i; } } cout << res; exit(false); } signed main(){ cin >> n; for(int i = 1; i <= n; ++i){ cin >> a[i]; } if(n <= 4 * 1000){ solve1(); } solve2(); }
#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...