#P4144. 大河的序列
大河的序列
Description
Dahe has some socks, but they are often piled up messily.
One day, Long'er couldn’t stand it anymore, so she placed the socks onto a sequence (called the sock sequence).
Each sock has a value. Define the value of the sock sequence as $\max \left( (dirty_{l} \ bitand \ dirty_{l+1} \ bitand \ \cdots \ bitand \ dirty_{r}) + (dirty_{l} \ bitor \ dirty_{l+1} \ bitor \ \cdots \ bitor \ dirty_{r}) \right)$, where denotes the value of the -th sock; means bitwise AND (in C++ it is &), and means bitwise OR (in C++ it is |).
In short, find a contiguous subsequence that maximizes the sum of the bitwise AND and the bitwise OR of all numbers in it.
If the value of this sock sequence reaches a certain threshold, then Long'er will dislike Dahe.
Of course, Dahe doesn’t want that, so she wants to know the value of this sock sequence.
Input Format
The first line contains three integers , representing the length of the sequence and output-related parameters.
The second line contains integers, the initial values of the sequence.
Output Format
Let the answer be . You need to output .
10 1 10000000
7 9 9 4 0 0 8 8 4 7
251
Hint
.
.
For the testdata of test points and , it is guaranteed that .
Translated by ChatGPT 5
京公网安备 11011102002149号