답안 #67820

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
67820 2018-08-15T10:29:21 Z MrTEK XOR Sum (info1cup17_xorsum) C++14
18 / 100
222 ms 6052 KB
#include <bits/stdc++.h>

using namespace std;
#define mp make_pair
#define pb push_back
#define len(a) (int)a.size()
#define fi first
#define sc second
#define left ind + ind
#define right ind + ind + 1
#define mid (l + r) / 2 
#define d1(w) cerr<<#w<<":"<<w<<endl;
#define d2(w,c) cerr<<#w<<":"<<w<<" "<<#c<<":"<<c<<endl;
#define d3(w,c,z) cerr<<#w<<":"<<w<<" "<<#c<<":"<<c<<" "<<#z<<":"<<z<<endl;
#define FAST_IO ios_base::sync_with_stdio(false);
#define endl '\n'

const int maxn = 620;
const long long LINF = 1e18;
const int LOG = 31;
const int INF = 1e9;
const int N = 1e6 + 5;
const int M = 4e3 + 5;
const int SQ = 350;
const int MOD = 998244353;

int n,mx,ans,mark[M],cnt[M * 2],ar[N];

typedef pair <int,int> pii;

int main() {

	scanf("%d",&n);

	for (int i = 1 ; i <= n ; i++) {
		scanf("%d",&ar[i]);
		mx = max(ar[i],mx);
	}

	if (n <= 4e3) {
		for (int i = 1 ; i <= n ; i++)
			for(int j = i ; j <= n ; j++)
				ans = ans ^ (ar[i] + ar[j]);
	}
	else if (mx <= 4e3){
		for (int i = 1 ; i <= n ; i++) mark[ar[i]]++;
		for (int i = 1 ; i <= 4e3; i++) {
			for (int j = i ; j <= 4e3 ; j++) {
				if (i == j && mark[i]) {
					cnt[i + j] += mark[i] * (mark[i] - 1) / 2 + mark[i];
				} else {
					if (mark[i] && mark[j]) {
						// d2(i,j);
						// d2(mark[i],mark[j]);
					}
					cnt[i + j] += mark[i] * mark[j];
				}
			}
		}
		// for (int i = 1 ; i <= 8e3 ; i++) {
		// 	if(cnt[i]) {
		// 		d2(i,cnt[i]);
		// 	}
		// }

		for (int j = 1 ; j <= 8e3 ; j++) if (cnt[j] & 1) ans = ans ^ j;
	}
	printf("%d\n",ans);
	return 0;
}

Compilation message

xorsum.cpp: In function 'int main()':
xorsum.cpp:33:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d",&n);
  ~~~~~^~~~~~~~~
xorsum.cpp:36:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d",&ar[i]);
   ~~~~~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 248 KB Output is correct
2 Correct 10 ms 484 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 157 ms 4360 KB Output is correct
2 Correct 150 ms 5716 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 157 ms 4360 KB Output is correct
2 Correct 150 ms 5716 KB Output is correct
3 Incorrect 222 ms 6052 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 248 KB Output is correct
2 Correct 10 ms 484 KB Output is correct
3 Incorrect 33 ms 6052 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 248 KB Output is correct
2 Correct 10 ms 484 KB Output is correct
3 Correct 157 ms 4360 KB Output is correct
4 Correct 150 ms 5716 KB Output is correct
5 Incorrect 222 ms 6052 KB Output isn't correct
6 Halted 0 ms 0 KB -