Блог пользователя hello_its_me

Автор hello_its_me, 12 месяцев назад, По-английски

I was trying to solve this problem from cses that is the maximum xor of a subarray of a given array. Can someone please help me to solve it. I tried for sometime but could not find any way.

This is the problem : Max Xor Subarray

Also it will be very helpful if you could give hints on solving the maximum Xor of subset of an array which i think is somewhat similar to the first problem. This one : Max Xor Subset

Thanks in advance.

  • Проголосовать: нравится
  • +3
  • Проголосовать: не нравится

»
12 месяцев назад, скрыть # |
 
Проголосовать: нравится +16 Проголосовать: не нравится

First one using binary trie.

Second one using xor basis.

»
12 месяцев назад, скрыть # |
 
Проголосовать: нравится +29 Проголосовать: не нравится

The maximum XOR subarray can be converted into the XOR of the maximum two XOR prefix sums, which can then be easily solved using 01-trie.

The maximum XOR subsets can be queried directly by inserting them into a linear basis.

»
12 месяцев назад, скрыть # |
 
Проголосовать: нравится +4 Проголосовать: не нравится

The two comments above me are literally giving the same, correct answer. Yet there's somehow a huge disparity in upvotes / downvotes. Make it make sense pls

»
12 месяцев назад, скрыть # |
 
Проголосовать: нравится -11 Проголосовать: не нравится

I think that you can use a slightly modified Kadane's algorithm. Instead of summing the values in the array, you just xor them.

code