Rating changes for last rounds are temporarily rolled back. They will be returned soon. ×

Maximize Sum of running XOR

Revision en1, by Arsh_a_d, 2022-08-03 10:41:01

Given a Cyclic Array 'A' of size N, we have to choose a 'cyclic subarray' R of length N itself in such a way that the value of R[0] + R[0]^R[1] + R[0]^R[1]^R[2] + ......... + R[0]^R[1]^R[2]^.....R[N-1]^R[N] is maximum.

[Note: ^ represents bitwise XOR.]

Example of Cyclic Array and Cyclic Subarray: Let's take a Cyclic Array, A = [2, 5, 1, 7, 9]

for index 0; [2, 5, 1, 7, 9] and [2, 9, 7, 1, 5] are two cyclic Subarray of length(A).

Similarly, for index 1; [5, 1, 7, 9, 2] and [5, 2, 9, 7, 1] are another two cyclic Subarray of length(A).

Similarly, for index 2; [1, 7, 9, 2, 5] and [1, 5, 2, 9, 7] are another two cyclic Subarray of length(A).

and so on.

What should be the approach to solve this problem? I tried Applying Trie and Gaussian Elimination but I am not able to come up with a solution.

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en6 English Arsh_a_d 2022-08-04 20:44:38 23 (published)
en5 English Arsh_a_d 2022-08-04 20:41:05 33 Tiny change: '....R[N-1]^R[N] is maximu' -> '....R[N-1] ~~^R[N]~~ is maximu' (saved to drafts)
en4 English Arsh_a_d 2022-08-03 12:56:11 6 Tiny change: 'N'** such a way that the ' -> 'N'** such that the '
en3 English Arsh_a_d 2022-08-03 12:54:11 475
en2 English Arsh_a_d 2022-08-03 10:44:51 24
en1 English Arsh_a_d 2022-08-03 10:41:01 855 Initial revision (published)