#P4098. [HEOI2013] ALO
[HEOI2013] ALO
Description
Welcome to ALO (Arithmetic and Logistic Online). This is a VR MMORPG. As the name suggests, it is full of math puzzles.
You have gems. The -th gem has an energy density , and all energy densities are pairwise distinct. You may select a contiguous segment of gems (with at least two gems) to fuse. Suppose their energy densities are . The fused gem’s energy density is the maximum value of the bitwise XOR between the second largest energy density in this segment and any other gem in the same segment. That is, if the second largest in this segment is , the generated energy density equals $\max\{k \oplus a_p \mid a_p \ne k,\ i \le p \le j\}$.
Find how to choose the segment to maximize the fused gem’s energy density.
Input Format
The first line contains an integer , the number of gems.
The second line contains integers, through , the energy density of each gem. It is guaranteed that for we have .
Output Format
Output one integer, the maximum possible fused gem energy density.
5
9 2 1 4 7
14
Hint
Sample Explanation
Choose the segment . The maximum is .
Constraints
- For of the testdata, .
- For of the testdata, .
- For of the testdata, , .
2023-04-28: Added two hack testdata, not scored.
Translated by ChatGPT 5
京公网安备 11011102002149号