답안 #522012

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
522012 2022-02-03T15:20:39 Z maks007 XOR Sum (info1cup17_xorsum) C++14
18 / 100
1600 ms 36452 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;
	sort(a.begin(), a.end());
	a.erase(unique(a.begin(), a.end()), a.end());
	for(int i = 0; i < a.size(); i ++) {
		for(int j = 0; j < a.size(); j ++) {
			if(a[j] < a[i]) {
				if(idx[a[i]]%2 and idx[a[j]]%2) {
					ans ^= (a[i] + a[j]);
				}
			}else if(a[j] == a[i]){
				int col = idx[a[i]] * (idx[a[i]] + 1) / 2;
				if(col % 2 == 1) {
					ans ^= (a[i] + a[j]);
				}
			}
		}
	}
	cout << ans;
	return false;
}

Compilation message

xorsum.cpp: In function 'int main()':
xorsum.cpp:17:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   17 |  for(int i = 0; i < a.size(); i ++) {
      |                 ~~^~~~~~~~~~
xorsum.cpp:18:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   18 |   for(int j = 0; j < a.size(); j ++) {
      |                  ~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 443 ms 580 KB Output is correct
2 Correct 435 ms 512 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 659 ms 5792 KB Output is correct
2 Correct 647 ms 8412 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 659 ms 5792 KB Output is correct
2 Correct 647 ms 8412 KB Output is correct
3 Execution timed out 1694 ms 36452 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 443 ms 580 KB Output is correct
2 Correct 435 ms 512 KB Output is correct
3 Execution timed out 1635 ms 6412 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 443 ms 580 KB Output is correct
2 Correct 435 ms 512 KB Output is correct
3 Correct 659 ms 5792 KB Output is correct
4 Correct 647 ms 8412 KB Output is correct
5 Execution timed out 1694 ms 36452 KB Time limit exceeded
6 Halted 0 ms 0 KB -