CF282E.Sausage Maximization

提高+/省选-

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

The Bitlandians are quite weird people. They have their own problems and their own solutions. They have their own thoughts and their own beliefs, they have their own values and their own merits. They have their own dishes and their own sausages!

In Bitland a sausage is an array of integers! A sausage's deliciousness is equal to the bitwise excluding OR (the xor operation) of all integers in that sausage.

One day, when Mr. Bitkoch (the local cook) was going to close his BitRestaurant, BitHaval and BitAryo, the most famous citizens of Bitland, entered the restaurant and each ordered a sausage.

But Mr. Bitkoch had only one sausage left. So he decided to cut a prefix (several, may be zero, first array elements) of the sausage and give it to BitHaval and a postfix (several, may be zero, last array elements) of the sausage and give it to BitAryo. Note that one or both pieces of the sausage can be empty. Of course, the cut pieces mustn't intersect (no array element can occur in both pieces).

The pleasure of BitHaval and BitAryo is equal to the bitwise XOR of their sausages' deliciousness. An empty sausage's deliciousness equals zero.

Find a way to cut a piece of sausage for BitHaval and BitAryo that maximizes the pleasure of these worthy citizens.

Bitland 的居民是一群非常奇特的人。他们有自己的问题和自己的解决方案,有自己的思想和信仰,有自己的价值观和优点,还有自己独特的菜肴和香肠!

在 Bitland,一根香肠就是一个整数数组!一根香肠的“美味度”等于该数组中所有整数的按位异或(即 xor 运算)。

某天,当当地厨师 Bitkoch 先生正准备关闭他的 BitRestaurant 餐厅时,Bitland 最著名的两位市民 —— BitHaval 和 BitAryo 走进了餐厅,并各自点了一根香肠。

但 Bitkoch 先生只剩最后一根香肠了。于是他决定:切下这根香肠的一个前缀(即数组最前面的若干个元素,可能为零个)给 BitHaval,再切下一根后缀(即数组最后面的若干个元素,可能为零个)给 BitAryo。注意:这两段切下的香肠可以为空;当然,它们不能相交(即任意数组元素至多只能属于其中一段)。

BitHaval 和 BitAryo 的“愉悦值”等于他们各自所得香肠的美味度的按位异或。空香肠的美味度定义为 00。

请找出一种切割方案,使得这两位杰出市民的愉悦值最大化。

输入格式

The first line contains an integer n (1 ≤ n ≤ 105).

The next line contains n integers _a_1, _a_2, ..., a__n (0 ≤ a__i ≤ 1012) — Mr. Bitkoch's sausage.

Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier.

第一行包含一个整数 nn(1≤n≤1051 \leq n \leq 10^5)。

第二行包含 nn 个整数 a1,a2,…,ana_1, a_2, \dots, a_n(0≤ai≤10120 \leq a_i \leq 10^{12})——Bitkoch 先生的香肠。

请注意,在 C++ 中读写 64 位整数时,请勿使用 %lld 格式说明符。推荐使用 cin、cout 流,或 %I64d 格式说明符。

输出格式

Print a single integer — the maximum pleasure BitHaval and BitAryo can get from the dinner.

输出一个整数——BitHaval 和 BitAryo 从晚餐中能获得的最大愉悦值。

输入输出样例

  • 输入#1

    2
    1 2

    输出#1

    3
  • 输入#2

    3
    1 2 3

    输出#2

    3
  • 输入#3

    2
    1000 1000

    输出#3

    1000

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

首页