Submission #3832874

Source Code Expand

Copy
#include <bits/stdc++.h>
using namespace std;

int solve(vector<int> A, vector<int> B, int N)
{
	sort(A.begin(), A.end());
	sort(B.begin(), B.end());
	long long ans = 0;
	for(auto x: A)
		ans += B.end() - lower_bound(B.begin(), B.end(), N-x);
	return ans%2;
}
int A[202020], B[202020];
int main() {
	int N;
	scanf("%d", &N);
	for(int i=0; i<N; ++i) scanf("%d", A+i);
	for(int i=0; i<N; ++i) scanf("%d", B+i);
	int ans = 0;
	for(int b=0; b<=29; ++b)
	{
		vector<int> X, Y, Z, W;
		int cnt1 = 0, cnt2 = 0;
		for(int i=0; i<N; ++i)
		{
			X.push_back(A[i]&((1<<b)-1));
			Y.push_back(B[i]&((1<<b)-1));
			if(A[i] & (1<<b)) ++cnt1;
			if(B[i] & (1<<b)) ++cnt2;
		}
		int c = solve(X, Y, (1<<b));
		if( (1LL*cnt1*(N-cnt2)+1LL*(N-cnt1)*(cnt2))%2 ) c = 1-c;
		ans += c<<b;
	}
	printf("%d\n", ans);
}

Submission Info

Submission Time
Task D - Two Sequences
User HYEA
Language C++14 (GCC 5.4.1)
Score 500
Code Size 827 Byte
Status
Exec Time 945 ms
Memory 5576 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:16:17: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &N);
                 ^
./Main.cpp:17:41: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  for(int i=0; i<N; ++i) scanf("%d", A+i);
                                         ^
./Main.cpp:18:41: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  for(int i=0; i<N; ++i) scanf("%d", B+i);
                                         ^

Test Cases

Set Name Score / Max Score Test Cases
Sample 0 / 0 example_0, example_1, example_2, example_3
All 500 / 500 N100000_0, N100000_1, N150000_0, N150000_1, N200000_0, N200000_1, N200000_ex_0, N200000_ex_1, example_0, example_1, example_2, example_3, rand_0, rand_1, smallrand_0, smallrand_1
Case Name Status Exec Time Memory
N100000_0 458 ms 3104 KB
N100000_1 459 ms 3104 KB
N150000_0 698 ms 4012 KB
N150000_1 695 ms 4012 KB
N200000_0 945 ms 5576 KB
N200000_1 941 ms 5576 KB
N200000_ex_0 902 ms 5576 KB
N200000_ex_1 905 ms 5576 KB
example_0 1 ms 256 KB
example_1 1 ms 256 KB
example_2 1 ms 256 KB
example_3 1 ms 256 KB
rand_0 26 ms 480 KB
rand_1 57 ms 656 KB
smallrand_0 1 ms 256 KB
smallrand_1 1 ms 256 KB