Submission #521985

# Submission time Handle Problem Language Result Execution time Memory
521985 2022-02-03T14:45:20 Z maks007 XOR Sum (info1cup17_xorsum) C++14
7 / 100
1600 ms 6296 KB
#include <bits/stdc++.h>
 
using namespace std;
 
int main(void) {
	int n;
	cin>> n;
	vector <int> a(n);
	map <int,int> idx;
	for(int i = 0; i < n; i ++ ) {
		cin >> a[i];
		idx[a[i]] ++;
	}
	int ans = 0;
	vector <int> even;
	sort(a.begin(), a.end());
	//a.erase(unique(a.begin(), a.end()), a.end());
	for(int k = 0; k < a.size(); k ++) {
		int i = a[k];
		if(idx[i] == 0) continue;
		if(idx[i] % 2 == 1) continue;
		for(auto j : even) {
			//cout << i + j << ' ';
			ans ^= (j+i);
		}
		even.push_back(i);
		ans ^= (i*2);
	}
	for(int i = 0; i < a.size(); i ++) {
		if(idx[a[i]] % 2 == 1){
			for(int j = i; j < a.size(); j ++) {
			//	cout << (a[i] + a[j]) << " ";
				ans ^= (a[i] + a[j]);
			}
		}
	}
	cout << ans;
	return false;
}

Compilation message

xorsum.cpp: In function 'int main()':
xorsum.cpp:18:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   18 |  for(int k = 0; k < a.size(); k ++) {
      |                 ~~^~~~~~~~~~
xorsum.cpp:29:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |  for(int i = 0; i < a.size(); i ++) {
      |                 ~~^~~~~~~~~~
xorsum.cpp:31:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |    for(int j = i; j < a.size(); j ++) {
      |                   ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 7 ms 460 KB Output is correct
2 Correct 8 ms 532 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1698 ms 5016 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1698 ms 5016 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 7 ms 460 KB Output is correct
2 Correct 8 ms 532 KB Output is correct
3 Execution timed out 1667 ms 6296 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 7 ms 460 KB Output is correct
2 Correct 8 ms 532 KB Output is correct
3 Execution timed out 1698 ms 5016 KB Time limit exceeded
4 Halted 0 ms 0 KB -