Codeforces и Polygon могут быть недоступны в период с 23 мая, 7:00 (МСК) по 23 мая, 11:00 (МСК) в связи с проведением технических работ. ×

Maximize Sum of running XOR

Правка en2, от Arsh_a_d, 2022-08-03 10:44:51

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 size(A) = N.

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

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.

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en6 Английский Arsh_a_d 2022-08-04 20:44:38 23 (published)
en5 Английский 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 Английский Arsh_a_d 2022-08-03 12:56:11 6 Tiny change: 'N'** such a way that the ' -> 'N'** such that the '
en3 Английский Arsh_a_d 2022-08-03 12:54:11 475
en2 Английский Arsh_a_d 2022-08-03 10:44:51 24
en1 Английский Arsh_a_d 2022-08-03 10:41:01 855 Initial revision (published)