Submission #1149292

#TimeUsernameProblemLanguageResultExecution timeMemory
1149292adlinXOR Sum (info1cup17_xorsum)C++20
11 / 100
46 ms4164 KiB
//#pragma GCC optimize("O3,unroll-loops")
//#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define F first
#define S second
#define all(v) (v).begin(),(v).end()
#define ull unsigned long long
#define ahahahant ios_base::sync_with_stdio(0);cin.tie(0); 
//#define int long long

using namespace std;

//mt19937 rng( chrono::steady_clock::now().time_since_epoch().count());
// 
//ll rand( ll l, ll r )
//{
//    uniform_int_distribution <ll> uid( l, r );
//    return uid( rng );
//}

ll lcm(ll x, ll y){
	return x / __gcd(x,y) * y;
}

ll binpow(ll a, ll b, ll m){
	if(!b) return 1ll;
	if(b & 1) return binpow(a,b-1,m) * a % m;
	int res = binpow(a,b/2,m) % m;
	return res * res % m;
}

const int maxn = 1e6 + 6;

const int mod = 1e9 + 7;

const int mod2 = 998244353;

const ll inf = 1e18;

const int inf2 = 1e9;

const int K = 300;

int n,a[maxn];

int cnt[4004];

void who(){
	
	cin >> n;
	
	int mx = 0;
	
	for(int i = 1; i <= n; i++) {
		cin >> a[i];
		mx = max(mx, a[i]);
	}
	
	if(0 && n <= 4000){
		int ans = 0;

		for(int i = 1; i <= n; i++){
			for(int j = i; j <= n; j++){
				ans ^= (a[i] + a[j]);
			}
		}
		
		cout << ans;			
	}
	else if(mx <= 4000){
		for(int i = 1; i <= n; i++){
			cnt[a[i]]++;
		}
		int ans = 0;
		for(int i = 1; i <= 4000; i++){
			int x = cnt[i] * 1ll * (cnt[i] + 1) / 2;
			if(x & 1){
//				cout << i << ' ' << ans << '\n';
				ans ^= (i + i);
			}
		}
		for(int i = 1; i <= 4000; i++){
			for(int j = i + 1; j <= 4000; j++){
				if(cnt[i] * 1ll * cnt[j] % 2){
					ans ^= (i + j);
//					cout << i << ' ' << j << ' ' << ans << '\n';
				}
			}
		}
		cout << ans;
	}
	
}

signed main(){
	
//	freopen("yinyang.in", "r", stdin);
//	freopen("yinyang.out", "w", stdout);
	
	ahahahant
		
	int tt = 1;
	
//	cin >> tt;
	
	while(tt--){
		who();
	}
	
	
	return 0;
}

/*
__builtin_popcount
__builtin_clz
__builtin_ctz
__builtin_parity
int get(int r){
	int res = 0;
	for(; r >= 0; r = (r & (r + 1)) - 1) res += f[r];
	return res;
}
 
void upd(int i, int val){
	for(; i <= n; i = (i | (i + 1))) f[i] += val;
}
*/ 	
#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...