답안 #521809

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
521809 2022-02-03T08:17:38 Z boykut XOR Sum (info1cup17_xorsum) C++14
18 / 100
158 ms 14756 KB
#include <bits/stdc++.h>

using namespace std ;

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin >> n;
	long long a[n];
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a, a + n);
	if (n <= 4000) {
		long long x = 0;
		for (int i = 0; i < n; i++) {
			for (int j = 0; j <= i; j++) {
				x ^= (a[i] + a[j]);
			}
		}
		cout << x << '\n';
	} else if (*max_element(a, a + n) <= 4000) {
		int N = *max_element(a, a + n);
		vector<int> cnt(N + 1, 0);
		for (int i = 0; i < n; i++) cnt[a[i]]++;
		long long x = 0;
		for (int i = 0; i <= N; i++) {
			for (int j = i; j <= N; j++) {
				int CNT = (i == j ? cnt[i] * (cnt[i] - 1) / 2 + cnt[i] : cnt[i] * cnt[j]);
				if (CNT % 2 == 1) {
					x ^= (i + j);
				}
			}
		}
		cout << x << '\n';
	}
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 332 KB Output is correct
2 Correct 5 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 137 ms 8112 KB Output is correct
2 Correct 135 ms 11908 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 137 ms 8112 KB Output is correct
2 Correct 135 ms 11908 KB Output is correct
3 Incorrect 158 ms 14756 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 332 KB Output is correct
2 Correct 5 ms 332 KB Output is correct
3 Incorrect 17 ms 972 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 332 KB Output is correct
2 Correct 5 ms 332 KB Output is correct
3 Correct 137 ms 8112 KB Output is correct
4 Correct 135 ms 11908 KB Output is correct
5 Incorrect 158 ms 14756 KB Output isn't correct
6 Halted 0 ms 0 KB -