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的值,也可以直接检验当前数组是否合法. # ...
随机推荐
- 476. Number Complement 二进制中的相反对应数
[抄题]: Given a positive integer, output its complement number. The complement strategy is to flip the ...
- Docker学习笔记_Dockerfile基本知识
Dockerfile由一行行命令语句组成,并支持以#开头的注释行. 1.编写一个Dockerfile文件 创建一个空的Docker工作目录,进入该目录,使用sudo vim Dockerfile指令新 ...
- 7. Smali基础语法总结
最近在学习Android 移动安全逆向方面,逆向首先要看懂代码,Android4.4之前一直使用的是 Dalivk虚拟机,而Smali是用于Dalivk的反汇编程序的实现. Smali 支持注解,调试 ...
- sublime text3安装后html:5+Tab不能快速生成html头部信息的解决办法
sublime text3安装后html:5+Tab不能快速生成html头部信息的解决办法: 需要下载Emmet插件,按网上写的步骤按ctrl+shift+P打开命令面板,输入install,鼠标点击 ...
- javascript总结5:js常见的数据类型
1 Number 数字类型 :包含正数,负数,小数 十进制表示: var n1 =23; 十六进制表示法:从0-9,a(A)-f(F)表示数字.以0x开头. var n2 = 0x42 2 字符串数据 ...
- Regularization and model selection
Suppose we are trying select among several different models for a learning problem.For instance, we ...
- Android AIDL--进程间通信
一 AIDL 是什么 AIDL(Android 接口定义语言) 是 Android 提供的一种进程间通信 (IPC) 机制. 我们可以利用它定义客户端与服务使用进程间通信 (IPC) 进行相互通信时都 ...
- Python中多使用迭代器
英文原文出处:Use More Iterators 本文介绍将代码转换为使用迭代器的原因和实用技巧. 我最喜欢的Python语言的特色之一是生成器,它们是非常有用的,然而当阅读开源代码时,我很少遇到它 ...
- OO 面向对象的三大特性
面向对象的三大特性 一.面向对象特性——封装: 概念:把对象所能操作的信息进行封装: 封装作用: 1.减少代码之间的耦合: 2.提供统一的访问接口,内部修改不影响外部的调用:(开放封闭原则) 二.面向 ...
- 搭建linux虚拟机
一.VMware 9 安装CentOS 7 -> 创建新虚拟机, 选择稍后安装操作系统 -> 选择Linux系统Centos 64位 -> 填写虚拟机名称, 选择虚拟机安 ...