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

Code G

The document describes a task to divide an array into the maximum number of segments such that each element is in one segment, each segment has at least one element, and there does not exist a non-empty subset of segments whose elements have a bitwise XOR of 0. The input is an array of integers, and the output is the maximum number of segments or -1 if no suitable division exists. The goal is to divide the array into as many segments as possible while satisfying the given constraints.

Uploaded by

Samin Afnan
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
65 views

Code G

The document describes a task to divide an array into the maximum number of segments such that each element is in one segment, each segment has at least one element, and there does not exist a non-empty subset of segments whose elements have a bitwise XOR of 0. The input is an array of integers, and the output is the maximum number of segments or -1 if no suitable division exists. The goal is to divide the array into as many segments as possible while satisfying the given constraints.

Uploaded by

Samin Afnan
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

 segment contains at least one element;

 there doesn't exist a non-empty subset of segmsegment contains at least one element;
 there doesn't exist a non-empty subset of segmsegment contains at least one element;
there doesn't exist a non-empty subset of segm
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