Submission #360827

# Submission time Handle Problem Language Result Execution time Memory
360827 2021-01-28T06:53:07 Z amunduzbaev XOR Sum (info1cup17_xorsum) C++14
56 / 100
1600 ms 4204 KB
#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 cnt[N], pr[40], pp[40];

void solve(int t_case){
	cin>>n;
	int mx = -1;
	for(int i=0;i<n;i++) cin>>a[i], mx = max(a[i], mx);
	ll res = 0;
	if(mx <= (4*(1e3))){
		for(int i=0;i<n;i++) cnt[a[i]]++, mx = max(a[i], mx); 
		for(int i=0;i<=mx;i++){
			if(!cnt[i]) continue;
			if(((cnt[i] * (cnt[i]-1) /2) + cnt[i]) % 2) res ^= (i + i); //{ cout<<i<<" "<<i<<"\n"; res ^= (i + i); }
			
			for(int j=0;j<i;j++){
				if(!cnt[j]) continue;
				if(cnt[j]%2 && cnt[i] % 2) res ^= (i+j); //{ cout<<i<<" "<<j<<"\n"; res ^= (i + j); }
			}
		}cout<<res<<"\n";
	}else{
		for(int i=0;i<n;i++){
			for(int j=i;j<n;j++){
				res ^= (a[i] + a[j]);
			}
		}cout<<res<<"\n";
	}
}

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 time Memory Grader output
1 Correct 5 ms 512 KB Output is correct
2 Correct 4 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 108 ms 4204 KB Output is correct
2 Correct 89 ms 3948 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 108 ms 4204 KB Output is correct
2 Correct 89 ms 3948 KB Output is correct
3 Execution timed out 1680 ms 4204 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 512 KB Output is correct
2 Correct 4 ms 364 KB Output is correct
3 Correct 1484 ms 1052 KB Output is correct
4 Correct 1458 ms 1132 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 512 KB Output is correct
2 Correct 4 ms 364 KB Output is correct
3 Correct 108 ms 4204 KB Output is correct
4 Correct 89 ms 3948 KB Output is correct
5 Execution timed out 1680 ms 4204 KB Time limit exceeded
6 Halted 0 ms 0 KB -