#P5283. [十二省联考 2019] 异或粽子
[十二省联考 2019] 异或粽子
Description
Xiao Zong is a good kid who likes eating zongzi. Today, she started making zongzi at home by herself.
There are different kinds of zongzi fillings in front of her. She places them in a row and numbers them from left to right as to . The -th kind of filling has a non-negative integer attribute value . Each kind of filling is available in unlimited quantity, so Xiao Zong will not be unable to make zongzi due to lack of ingredients. She plans to use these fillings to make zongzi.
Her method is: choose two integers and such that , mix all fillings with indices in the range to make one zongzi. The tastiness of the resulting zongzi is the xor sum of the attribute values of these fillings. (Xor is the operation we usually call xor, i.e. the ˆ operator in C/C++ or the xor operator in Pascal.)
Xiao Zong wants to taste different flavors, so she does not want to make more than one zongzi using the same set of fillings.
She wants the sum of tastiness of all the zongzi she makes to be as large as possible. Please help her compute this value.
Input Format
The first line contains two positive integers and , representing the number of fillings and the number of zongzi Xiao Zong plans to make.
The next line contains non-negative integers. The -th number is , representing the attribute value of the -th filling.
For all input data: , $1 \leqslant k \leqslant \min\left\{\frac{n(n-1)}{2},2 \times 10^{5}\right\}$, .
Output Format
Output one integer on a single line, representing the maximum possible sum of tastiness of the zongzi Xiao Zong can make.
3 2
1 2 3
6
Hint
| Test Point | ||
|---|---|---|
| , , , , , , , | ||
| , , , | ||
| , , , | ||
| , , , |
Translated by ChatGPT 5
京公网安备 11011102002149号