0% found this document useful (0 votes)
53 views

Code G

You are given an array of integers and must divide it into the maximum number of segments where: - Each element is in one segment - Each segment has at least one element - The bitwise XOR of any non-empty subset of segments cannot be 0 Print the maximum number of segments or -1 if no valid division exists.

Uploaded by

Samin Afnan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
53 views

Code G

You are given an array of integers and must divide it into the maximum number of segments where: - Each element is in one segment - Each segment has at least one element - The bitwise XOR of any non-empty subset of segments cannot be 0 Print the maximum number of segments or -1 if no valid division exists.

Uploaded by

Samin Afnan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

can be divided into.

Print -1 if no suitable division Print the maximum number of segments the array
can be divided into. Print -1 if no suitable division Print the maximum number of segments the array
can be divided into. Print -1 if no suitable division
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

Examples
input
Copy
4
5 5 7 2
output
Copy
2

input
Copy
3
1 2 3
output
Copy

Your task is to divide the array into the maximum number of segments in such a way that:
 each element is contained in exactly one segment;
 each segment contains at least one element;
 there doesn't exist a non-empty subset of segments such that bitwise XOR of the numbers from
them is equal to 00.

You are given an array a1,a2,…,ana1,a2,…,an of integer numbers.

Your task is to divide the array into the maximum number of segments in such a way that:
G. (Zero XOR Subset)-less
You are given an array a1,a2,…,ana1,a2,…,an of integer numbers.

Your task is to divide the array into the maximum number of segments in such a way that:
 each element is contained in exactly one segment;
 each segment contains at least one element;
 there doesn't exist a non-empty subset of segments such that bitwise XOR of the numbers from
them is equal to 00.

Print the maximum number of segments the array can be divided into. Print -1 if no suitable division
exists.
Input
The first line contains a single integer nn (1≤n≤2⋅1051≤n≤2⋅105) — the size of the array.
The second line contains nn integers a1,a2,…,ana1,a2,…,an (0≤ai≤1090≤ai≤109).
Output

Print the maximum number of segments the array can be divided into while following the given
constraints. Print -1 if no suitable division exists.

Examples
input
Copy
4
5 5 7 2
output
Copy
2

input
Copy
3
1 2 3
output
Copy
-1

input
Copy
3
3 1 10
output
Copy
3

You might also like