Submission #521978

# Submission time Handle Problem Language Result Execution time Memory
521978 2022-02-03T14:39:13 Z maks007 XOR Sum (info1cup17_xorsum) C++14
0 / 100
1600 ms 10028 KB
#include <bits/stdc++.h>
 
using namespace std;
 
int main(void) {
	int n;
	cin>> n;
	vector <int> a(n);
	vector <int> idx((int)1e6, 0);
	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 Runtime error 5 ms 8388 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1676 ms 10028 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1676 ms 10028 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 5 ms 8388 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 5 ms 8388 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -