UVALive - 4682
/*H E A D*/
struct Trie{
int son[maxn<<2][2];
int b[67],tot;
void init(){
// memset(son,0,sizeof son);
tot=0;
son[0][0]=son[0][1]=0;
}
void insert(ll x){
int now=0;
rep(i,0,32) b[i]=(x>>i)&1;
rrep(i,32,0){
if(!son[now][b[i]]){
son[now][b[i]]=++tot;
son[tot][0]=son[tot][1]=0;
}
now=son[now][b[i]];
}
}
ll find(ll x){
int now=0;
ll ans=0;
rep(i,0,32) b[i]=(x>>i)&1;
rrep(i,32,0){
if(son[now][b[i]^1]){
now=son[now][b[i]^1];
ans+=1ll<<i;
}else{
now=son[now][b[i]];
}
}
return ans;
}
}trie;
ll a[maxn];
int main(){
int T=read();
while(T--){
int n=read();
rep(i,1,n) a[i]=read();
rep(i,2,n) a[i]^=a[i-1];
trie.init();
rep(i,1,n) trie.insert(a[i]);
ll ans=-oo;
rep(i,0,n) ans=max(ans,trie.find(a[i]));//0->n
println(ans);
}
return 0;
}
UVALive - 4682的更多相关文章
- UVALive 4682 XOR Sum (trie)
题意:求一段连续的数字使得它们的异或和最大. 思路:首先利用前缀和求sum[i],这样求某段连续数字异或和最大就是求某两个j和i满足sum[i]^sum[j-1]最大,问题就变成了找两个数的异或最大. ...
- UVALive - 4108 SKYLINE[线段树]
UVALive - 4108 SKYLINE Time Limit: 3000MS 64bit IO Format: %lld & %llu Submit Status uDebug ...
- UVALive - 3942 Remember the Word[树状数组]
UVALive - 3942 Remember the Word A potentiometer, or potmeter for short, is an electronic device wit ...
- UVALive - 3942 Remember the Word[Trie DP]
UVALive - 3942 Remember the Word Neal is very curious about combinatorial problems, and now here com ...
- 思维 UVALive 3708 Graveyard
题目传送门 /* 题意:本来有n个雕塑,等间距的分布在圆周上,现在多了m个雕塑,问一共要移动多少距离: 思维题:认为一个雕塑不动,视为坐标0,其他点向最近的点移动,四舍五入判断,比例最后乘会10000 ...
- UVALive 6145 Version Controlled IDE(可持久化treap、rope)
题目链接:https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show_ ...
- UVALive 6508 Permutation Graphs
Permutation Graphs Time Limit:3000MS Memory Limit:0KB 64bit IO Format:%lld & %llu Submit ...
- UVALive 6500 Boxes
Boxes Time Limit:3000MS Memory Limit:0KB 64bit IO Format:%lld & %llu Submit Status Pract ...
- UVALive 6948 Jokewithpermutation dfs
题目链接:UVALive 6948 Jokewithpermutation 题意:给一串数字序列,没有空格,拆成从1到N的连续数列. dfs. 可以计算出N的值,也可以直接检验当前数组是否合法. # ...
随机推荐
- 11-内涵段子-爬虫(python+正则)
爬取内涵段子,使用正则进行简单处理: #_*_ coding: utf-8 _*_ ''' Created on 2018年7月14日 @author: sss function:爬去内涵段子(静态网 ...
- 使用 tpl 标签和 for 读取对象属性值中的数组
来源于<sencha touch 权威指南> ----------------------------- 只摘抄app.js代码: Ext.require(['Ext.form.Panel ...
- 用conda创建一个tensorflow 虚拟环境
创建your——user——name = tensorflow 的虚拟环境 xinpingdeMacBook-Pro:~ xinpingbao$ conda create -n tensorflow ...
- 2.3.1 java 内存模型
在前面谈到了一些关于内存模型以及并发编程中可能会出现的一些问题.下面我们来看一下Java内存模型,研究一下Java内存模型为我们提供了哪些保证以及在java中提供了哪些方法和机制来让我们在进行多线程编 ...
- 列表推导式对比For循环执行效率
我们在前面的学习中都知道,如果把1-10以内的元素追加到一个新的列表表中,如果使用for循环我们可以这么做: a = [] for i in range(1,11): a.append(i) prin ...
- C++面试基础
自己整理了一些常见的面试题,频率挺高的都是,而且感觉这里这些基础的东西都会问,自己过几天也要面试了,所以发上来让大家一起看看,有什么错误的地方望提醒我纠正. 32位数据类型以及sizeof大小. ch ...
- HttpAnalyzerStdV7安装教程
相关链接:HttpAnalyzerStdV7使用教程 安装步骤: 1.解压压缩包 2.双击运行安装文件 3.根据向导提示点击Next 4.选择接受协议,点击Next 5.修改安装路 ...
- 20169219 TCP_IP网络协议攻击实验报告
(1) ARP缓存欺骗 RP 缓存是 ARP 协议的重要组成部分.ARP 协议运行的目标就是建立 MAC 地址和 IP 地址的映射,然后把这一映射关系保存在 ARP 缓存中,使得不必重复运行 ARP ...
- 递增三元数组——第九届蓝桥杯C语言B组(省赛)第六题
原创 标题:递增三元组 给定三个整数数组A = [A1, A2, ... AN], B = [B1, B2, ... BN], C = [C1, C2, ... CN],请你统计有多少个三元组(i, ...
- Graphics 小记
1.切图 drowg.DrawImage(productImg1, new System.Drawing.Rectangle(30, 30, 300, 300), new System.Drawing ...