#P7335. [JRKSJ R1] 异或

    ID: 8144 远端评测题 1200ms 128MiB 尝试: 0 已通过: 0 难度: 6 上传者: 标签>动态规划 DP2021洛谷原创O2优化字典树 Trie其它技巧

[JRKSJ R1] 异或

Problem Description

You are given nn, kk, and a sequence a1,2na_{1,2\dots n}. Choose kk disjoint intervals [li,ri][1,n][l_i, r_i] \subseteq [1, n], and compute

$$\max_{l_i,r_i}\sum_{i=1}^k\bigoplus_{j=l_i}^{r_i}a_j$$

Here, \oplus denotes the bitwise XOR operation.

The testdata is guaranteed to be random.

Input Format

The input has 22 lines.
The first line contains two integers n,kn, k.
The second line contains nn non-negative integers representing the sequence aa.

Output Format

Output one non-negative integer in one line, which is the maximum value of the expression.

6 3
2 1 3 4 4 4
15
7 2
3 4 5 6 7 8 9
24

Hint

Sample 1 Explanation

The three intervals chosen in the sequence are:

2,1,[3,4],[4],[4]2,1,[3,4],[4],[4]

The sum of XOR values of the three intervals is 7+4+4=157+4+4=15.

Constraints

For all testdata, it is guaranteed that 1kn30001\le k\le n\le 3000 and 0ai1090\le a_i\le 10^{9}. The testdata is guaranteed to be random.

This problem uses bundled tests.

Subtask\text{Subtask} nn\le Special Property Score
11 3030 k3k\le3 55
22 500500 ai107a_i\le10^7 1010
33 10001000 None
44 15001500 1515
55 20002000
66 25002500 2020
77 30003000 2525

Translated by ChatGPT 5