Submission #673985

# Submission time Handle Problem Language Result Execution time Memory
673985 2022-12-22T13:43:31 Z QwertyPi XOR Sum (info1cup17_xorsum) C++14
45 / 100
1600 ms 21828 KB
#include <bits/stdc++.h>
#define int long long
using namespace std;

const int N = 1e6 + 11;
int a[N], b0[N], b0n, b1[N], b1n;

int32_t main(){
	int n; cin >> n;
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	int ans = 0;
	for(int s = 0; s <= 29; s++){
		int c = 0;
		b0n = b1n = 0;
		for(int j = 0; j < n; j++){
			if(a[j] & (1 << s)) b1[b1n++] = a[j] % (1 << s);
			else b0[b0n++] = a[j] % (1 << s);
		}
		sort(b0, b0 + b0n); sort(b1, b1 + b1n);
		int r = b0n;
		for(int l = 0; l < b0n; l++){
			r = max(r, l + 1);
			while(r - 1 > l && b0[l] + b0[r - 1] >= (1 << s)) r--;
			c += b0n - r;
		}
		
		r = b1n;
		for(int l = 0; l < b1n; l++){
			r = max(r, l + 1);
			while(r - 1 > l && b1[l] + b1[r - 1] >= (1 << s)) r--;
			c += b1n - r;
		}
		
		r = b1n;
		for(int l = 0; l < b0n; l++){
			while(r > 0 && b0[l] + b1[r - 1] >= (1 << s)) r--;
			c += b1n - r;
		}
		
		c += b0n * b1n;
		
		ans ^= (1 << s) * (c % 2); 
	}
	for(int i = 0; i < n; i++){
		ans ^= (a[i] * 2);
	}
	cout << ans << endl;
}
# Verdict Execution time Memory Grader output
1 Correct 9 ms 340 KB Output is correct
2 Correct 8 ms 440 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1690 ms 21828 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1690 ms 21828 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 9 ms 340 KB Output is correct
2 Correct 8 ms 440 KB Output is correct
3 Correct 221 ms 3348 KB Output is correct
4 Correct 216 ms 3368 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 9 ms 340 KB Output is correct
2 Correct 8 ms 440 KB Output is correct
3 Execution timed out 1690 ms 21828 KB Time limit exceeded
4 Halted 0 ms 0 KB -