답안 #67958

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
67958 2018-08-15T15:35:05 Z ekrem XOR Sum (info1cup17_xorsum) C++
45 / 100
1600 ms 16156 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;
typedef vector < int > vi;

int n, ans, a[N];
pair < int , int > 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);
	}
	sort(b + 1, b + n + 1);
	for(int k = 0; k <= 28; k++){
		int x = n + 1, y = n + 1, z = n + 1, say = 0;
		for(int i = 1; i <= n; i++){
			while(x >= 2 and b[x - 1] >= mp((1<<k) - b[i].st ,0))x--;
			while(y >= 2 and b[y - 1] >= mp((1<<(k+1) ) - b[i].st ,0))y--;
			while(z >= 2 and b[z - 1] >= mp((1<<k) + (1<<(k+1)) - b[i].st ,0))z--;
			say += max(y, i) - max(x, i);
			say += n - max(z, i) + 1;
			say = say%2;
			// printf("%d %d %d\n",x ,y ,z);
		}
		// cout << "\nAMK\n";
		int ind = 0, 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];
			// b[i].st += a[b[i].nd ]&(1<<(k + 1));
		}
		for(int i = 1; i <= xx; i++)
			b[++ind] = c[i];
		sort(b + 1, b + n + 1);
		ans += (1<<k)*(say%2);
	}
	printf("%d\n", ans);
	return 0;
}

Compilation message

xorsum.cpp: In function 'int main()':
xorsum.cpp:18:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d",&n);
  ~~~~~^~~~~~~~~
xorsum.cpp:20: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 8 ms 376 KB Output is correct
2 Correct 10 ms 484 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1660 ms 16156 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1660 ms 16156 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 376 KB Output is correct
2 Correct 10 ms 484 KB Output is correct
3 Correct 175 ms 16156 KB Output is correct
4 Correct 169 ms 16156 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 376 KB Output is correct
2 Correct 10 ms 484 KB Output is correct
3 Execution timed out 1660 ms 16156 KB Time limit exceeded
4 Halted 0 ms 0 KB -