답안 #67964

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
67964 2018-08-15T15:45:16 Z ekrem XOR Sum (info1cup17_xorsum) C++
100 / 100
1428 ms 18348 KB
#include <bits/stdc++.h>
#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define N 1000005
using namespace std;

typedef pair < int , int > ii;

int n, ans, ind, xx, x, y, z, say, a[N];
ii b[N], c[N];

int main() {
	// freopen("in.txt", "r", stdin);
	// freopen("out.txt", "w", stdout);
	scanf("%d",&n);
	for(int i = 1; i <= n; i++){
		scanf("%d",a + i);
		b[i] = mp(a[i]%2, i);
	}
	for(int i = 1; i <= n; i++){
		if(b[i].st)
			c[++xx] = b[i];
		else
			b[++ind] = b[i];
	}
	for(int i = 1; i <= xx; i++)
			b[++ind] = c[i];
	for(int k = 0; k <= 29; k++){
		x = y = z = n + 1;
		say = 0;
		for(int i = 1; i <= n; i++){
			while(x >= 2 and b[x - 1].st >= (1<<k) - b[i].st)x--;
			while(y >= 2 and b[y - 1].st >= (1<<(k+1) ) - b[i].st)y--;
			while(z >= 2 and b[z - 1].st >= (1<<k) + (1<<(k+1)) - b[i].st)z--;
			say += max(y, i) - max(x, i);
			say += n - max(z, i) + 1;
			say = say%2;
		}
		ind = xx = 0;
		for(int i = 1; i <= n; i++){
			if(a[b[i].nd ]&(1<<(k + 1)))
				c[++xx] = (mp(b[i].st + (a[b[i].nd ]&(1<<(k + 1))) , b[i].nd));
			else
				b[++ind] = b[i];
		}
		for(int i = 1; i <= xx; i++)
			b[++ind] = c[i];
		ans += (1<<k)*(say%2);
	}
	printf("%d\n", ans);
	return 0;
}

Compilation message

xorsum.cpp: In function 'int main()':
xorsum.cpp:17:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d",&n);
  ~~~~~^~~~~~~~~
xorsum.cpp:19:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d",a + i);
   ~~~~~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 376 KB Output is correct
2 Correct 8 ms 484 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 803 ms 18120 KB Output is correct
2 Correct 760 ms 18120 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 803 ms 18120 KB Output is correct
2 Correct 760 ms 18120 KB Output is correct
3 Correct 1012 ms 18240 KB Output is correct
4 Correct 908 ms 18240 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 376 KB Output is correct
2 Correct 8 ms 484 KB Output is correct
3 Correct 131 ms 18240 KB Output is correct
4 Correct 107 ms 18240 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 376 KB Output is correct
2 Correct 8 ms 484 KB Output is correct
3 Correct 803 ms 18120 KB Output is correct
4 Correct 760 ms 18120 KB Output is correct
5 Correct 1012 ms 18240 KB Output is correct
6 Correct 908 ms 18240 KB Output is correct
7 Correct 131 ms 18240 KB Output is correct
8 Correct 107 ms 18240 KB Output is correct
9 Correct 1428 ms 18344 KB Output is correct
10 Correct 1428 ms 18344 KB Output is correct
11 Correct 1387 ms 18348 KB Output is correct