제출 #361149

#제출 시각아이디문제언어결과실행 시간메모리
361149amunduzbaevXOR Sum (info1cup17_xorsum)C++14
0 / 100
421 ms8300 KiB
#include <bits/stdc++.h> using namespace std; #pragma GCC optimize("Ofast,unroll-loops") #pragma GCC target("avx,avx2,fma") #define ff first #define ss second #define pb push_back #define mp make_pair #define ub upper_bound #define lb lower_bound #define sz(x) (int)x.size() #define all(x) x.begin(), x.end() #define rall(x) x.rbegin(),x.rend() #define NeedForSpeed ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); typedef long long ll; typedef long double ld; typedef pair<int, int> pii; typedef pair<ll, ll> pll; typedef vector<ll> vll; typedef vector<int> vii; typedef vector<pll> vpll; typedef vector<pii> vpii; template<class T> bool umin(T& a, const T& b) {return a > b? a = b, true:false;} template<class T> bool umax(T& a, const T& b) {return a < b? a = b, true:false;} int msb(int val){return sizeof(int)*8-__builtin_clzll(val)-1;} const int N = 1e6+5; const int mod = 1e9+7; const ll inf = 1e18; const ld Pi = acos(-1); #define MULTI 0 int n, m, s, k, ans, a[N]; int c[N]; void solve(int t_case){ cin>>n; for(int i=0;i<n;i++) cin>>a[i]; int res = 0; sort(a, a+n); for(int i=0;i<=29;i++){ int b = (1 << i), last = 0; ll tt = 0; if(i) for(int j=0;j<n;j++) if(!(a[j] >> (i-1) & 1)) c[last++] = a[j]; if(i) for(int j=0;j<n;j++) if(a[j] >> (i-1) & 1) c[last++] = a[j]; if(i) for(int j=0;j<n;j++) c[j] %= b; //for(int j=0;j<n;j++) cout<<c[j]<<" "; cout<<"\n"; //for(int j=0;j<n;j++) cout<<a[j]<<" "; cout<<"\n"; for(int j=0;j<n;j++) if(a[j] >> i & 1) tt++; ll k = 0; int l = 0, r = n-1; while(l < n){ while(c[l] + c[r] >= b) r--; k += (n - r - 1); l++; } //for(int i=0;i<n;i++) if(2*c[i] >= b) k++; for(int j=0;j<n;j++) if(2*c[j] >= b) k++; if( ( k / 2 + tt * (n - tt) ) & 1 ) res |= b; } cout<<res<<"\n"; //cout<<"\n________\n"; } /* 4 3 6 6 9 */ signed main(){ NeedForSpeed if(!MULTI){ solve(1); } else{ int t; cin>>t; for(int t_case = 1; t_case <= t; t_case++) solve(t_case); } 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...