Submission #496784

# Submission time Handle Problem Language Result Execution time Memory
496784 2021-12-22T04:30:20 Z Ierus XOR Sum (info1cup17_xorsum) C++17
45 / 100
1600 ms 31636 KB
#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)1e6;
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+3, 0), s(N+N+4,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)N+N; ++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 <= 1e5){
		solve1();
	}
	solve2();
}











# Verdict Execution time Memory Grader output
1 Correct 3 ms 204 KB Output is correct
2 Correct 3 ms 312 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1679 ms 31636 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1679 ms 31636 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 204 KB Output is correct
2 Correct 3 ms 312 KB Output is correct
3 Correct 966 ms 1060 KB Output is correct
4 Correct 1012 ms 1060 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 204 KB Output is correct
2 Correct 3 ms 312 KB Output is correct
3 Execution timed out 1679 ms 31636 KB Time limit exceeded
4 Halted 0 ms 0 KB -