For those people who had no better thing to do on February the 14th
AC count:
xorsplit: 2, including 2 authors
motest: 15, including author
The score of a group is defined as the XOR of all of its elements. You start with an empty list, and are to handle Q updates. At every update, one of two things will happen:
After every update, split the integers into 2 groups such that the sum of the scores of the groups is maximised. Output this after every update.
This problem was initially intended to be for EC³'s CP training final contest. However, we only found that the problem was EE after being unable to solve it and asking pavement, who gave a solution. After consulting zane and maomao90, we figured out a solution, allowing maomao90 to buff the problem.
Let's try to solve the problem at a single time unit. Note that for each bit, there are 2 cases:
After processing the first type of bits, we are left with N numbers, each bit appearing an even number of times, trying to find a selection of numbers that maximises the sum of the bits that can contribute twice. Note how the XOR of all of these new numbers is 0. Hence, the problem is reduced to finding the maximum subset XOR of N numbers, which can be solved in using xor basis.
Note how we can consider the operation that does the simplified problem as a data structure. We can implement additions and deletions with an additional log factor using DnC. This method is very classic and is left as a problem for the reader.
Time complexity:
© 2022-2024 HCI EC3. All rights reserved.
Made with ❤️, Next.js, and Tailwind CSS • b1fc641 • Built a year ago