#P5514. [MtOI2019] 永夜的报应
[MtOI2019] 永夜的报应
Description
Houraisan Kaguya (Kaguya) has a bunch of numbers.
Kaguya has non-negative integers . Since Kaguya went to play a Gal Game, she hopes that you, who are wise, can help.
- You need to divide these numbers into several groups, such that each of the numbers is assigned to exactly one group, and each group contains at least one number.
Define the weight of a group as the xor sum of all numbers in that group. Please find a grouping plan that minimizes the sum of the weights of all groups, and output this minimum value.
Input Format
The first line contains a positive integer , representing the number of given non-negative integers.
The next line contains non-negative integers .
Output Format
Output one line with one integer representing the answer.
3
1 2 5
6
6
9 18 36 25 9 32
15
Hint
Explanation for Sample :
One optimal grouping plan is:
- Put the st number and the rd number into one group, whose weight is .
- Put the nd number into one group, whose weight is .
The sum of the weights of all groups is . It can be proven that there is no grouping plan with a smaller total weight sum.
Explanation for Sample :
One optimal grouping plan is:
- Put the st number and the th number into one group, whose weight is .
- Put the nd number and the th number into one group, whose weight is .
- Put the rd number and the th number into one group, whose weight is .
The sum of the weights of all groups is . It can be proven that there is no grouping plan with a smaller total weight sum.
Subtasks
- For of the testdata, .
- For of the testdata, .
Source
Lost Home 2019 League (MtOI2019) T1
Problem setter: disangan233
Translated by ChatGPT 5
京公网安备 11011102002149号