CF280B.Maximum Xor Secondary

普及+/提高

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Bike loves looking for the second maximum element in the sequence. The second maximum element in the sequence of distinct numbers _x_1, _x_2, ..., x__k (k > 1) is such maximum element x__j, that the following inequality holds: .

The lucky number of the sequence of distinct positive integers _x_1, _x_2, ..., x__k (k > 1) is the number that is equal to the bitwise excluding OR of the maximum element of the sequence and the second maximum element of the sequence.

You've got a sequence of distinct positive integers _s_1, _s_2, ..., s__n (n > 1). Let's denote sequence s__l, s__l + 1, ..., s__r as s[l..r] (1 ≤ l < r ≤ n). Your task is to find the maximum number among all lucky numbers of sequences s[l..r].

Note that as all numbers in sequence s are distinct, all the given definitions make sence.

Bike 喜欢在序列中寻找第二大的元素。对于由互不相同的数 x1,x2,…,xkx_1, x_2, \dots, x_k(其中 k>1k > 1)构成的序列,其第二大的元素是指满足如下不等式的最大元素 xjx_j:
。

对于由互不相同的正整数组成的序列 x1,x2,…,xkx_1, x_2, \dots, x_k(其中 k>1k > 1),其“幸运数”定义为该序列中最大元素与第二大元素的按位异或(XOR)结果。

现给定一个由互不相同的正整数组成的序列 s1,s2,…,sns_1, s_2, \dots, s_n(其中 n>1n > 1)。记子序列 sl,sl+1,…,srs_l, s_{l+1}, \dots, s_r 为 s[l..r]s[l..r](其中 1≤l<r≤n1 \le l < r \le n)。你的任务是求出所有子序列 s[l..r]s[l..r] 的幸运数中的最大值。

注意:由于序列 ss 中所有数互不相同,上述所有定义均有意义。

输入格式

The first line contains integer n (1 < n ≤ 105). The second line contains n distinct integers _s_1, _s_2, ..., s__n (1 ≤ s__i ≤ 109).

第一行包含一个整数 nn(1<n≤1051 < n \leq 10^5)。第二行包含 nn 个互不相同的整数 s1,s2,…,sns_1, s_2, \dots, s_n(1≤si≤1091 \leq s_i \leq 10^9)。

输出格式

Print a single integer — the maximum lucky number among all lucky numbers of sequences s[l..r].

输出一个整数——所有子序列 s[l..r]s[l..r] 的幸运数中的最大幸运数。

输入输出样例

  • 输入#1

    5
    5 2 1 4 3

    输出#1

    7
  • 输入#2

    5
    9 8 3 5 7

    输出#2

    15

说明/提示

For the first sample you can choose s[4..5] = {4, 3} and its lucky number is (4 xor 3) = 7. You can also choose s[1..2].

For the second sample you must choose s[2..5] = {8, 3, 5, 7}.

对于第一个样例,你可以选择子序列 s[4..5]={4,3}s[4..5] = \{4, 3\},其幸运数为 (4 xor 3)=7(4 \text{ xor } 3) = 7。你也可以选择 s[1..2]s[1..2]。

对于第二个样例,你必须选择子序列 s[2..5]={8,3,5,7}s[2..5] = \{8, 3, 5, 7\}。

输入解题思路,AI测评打分。不知道怎么写?

首页