제출 #1149394

#제출 시각아이디문제언어결과실행 시간메모리
1149394arkanefuryXOR Sum (info1cup17_xorsum)C++20
18 / 100
1696 ms85256 KiB
#include <bits/stdc++.h> using namespace std; #define pb push_back #define in insert #define lb lower_bound #define F first #define S second #define sz size() #define all(v) v.begin(),v.end() #define FOR1(x, n) for(int j = x; j <= n; j ++) #define FOR(x, n, m, d) for(int x = n; x <= m; x += d) #define FORR(x, n, m, d) for(int x = n; x >= m; x -= d) #define nikita ios_base::sync_with_stdio(0), cin.tie(0); const int N = 1e6+5; int a[N], b[N], pref[N], dp[N]; int n,m,k,sum=0,x,y, ans, r, cnt, l, mod = 1e9+7, mt[N]; bool used[N]; vector<int>g[N]; string s, str; map<int, int>mp; void solve(){ nikita cin >> n; ans = 0; vector<int>v; int mx = 0; set<int>st; FOR(i, 1, n, 1)cin >> a[i], st.in(a[i]); k = 1; for(auto i : st)mp[i] = k, k ++; FOR(i, 1, n, 1){ b[mp[a[i]]]++; if(b[mp[a[i]]] == 1)v.pb(a[i]); } if(n <= 6e3){ ans = 0; FOR(i, 1, n, 1){ FOR(j, i, n, 1){ ans ^= (a[i] + a[j]); } } cout << ans; return; } FOR(i, 0, v.sz-1, 1){ FOR(j, i, v.sz-1, 1){ if(v[i] == v[j]){ if((b[mp[v[i]]] * (b[mp[v[i]]] - 1) / 2 + b[mp[v[i]]]) % 2)ans ^= (v[i] * 2); continue; } if(b[mp[v[i]]] * b[mp[v[j]]] % 2)ans ^= (v[i] + v[j]); } } cout << ans; } signed main(){ nikita int tt = 1; if(!tt)cin >> tt; FOR(i, 1, tt, 1)solve(); }
#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...