BZOJ 4260 trie树
来源:互联网 发布:推理软件 编辑:程序博客网 时间:2024/06/06 07:10
思路:
搞一个前缀异或和
一次从左往右 另一次从右往左 异或最大值
用字典树搞一搞
//By SiriusRen#include <cstdio>#include <cstring>#include <algorithm>using namespace std;#define N 400500int n,a[N],cnt=1,ch[N*20][2],sum[N],lmax[N],rmax[N],ans;bool f;void insert(int x){ int now=1; for(int i=30;~i;i--){ f=x&(1<<i); if(!ch[now][f])ch[now][f]=++cnt; now=ch[now][f]; }}int query(int x){ int now=1,temp=0; for(int i=30;~i;i--){ f=x&(1<<i); if(ch[now][!f])temp+=(1<<i),now=ch[now][!f]; else now=ch[now][f]; }return temp;}int main(){ scanf("%d",&n); insert(0); for(int i=1;i<=n;i++){ scanf("%d",&a[i]); sum[i]=sum[i-1]^a[i]; lmax[i]=max(lmax[i-1],query(sum[i])); insert(sum[i]); } cnt=1,memset(ch,0,sizeof(ch)); for(int i=n;i;i--){ sum[i]=sum[i+1]^a[i]; rmax[i]=max(rmax[i+1],query(sum[i])); ans=max(ans,rmax[i+1]+lmax[i]); insert(sum[i]); } printf("%d\n",ans);}
0 0
- BZOJ 4260 trie树
- BZOJ 4260: Codechef REBXOR|Trie树
- BZOJ 2251 Trie树
- 【BZOJ 4260】 Codechef REBXOR|trie
- bzoj 4260: Codechef REBXOR Trie
- bzoj 3689 trie树+堆
- BZOJ 4260 Codechef REBXOR 可持久化Trie树
- 【BZOJ 4260】Codechef REBXOR 可持久化trie树
- BZOJ 4260 Codechef REBXOR trie树+树状数组
- BZOJ 4260 Codechef REBXOR 01Trie
- BZOJ 4260 REBXOR 异或Trie+dp
- BZOJ 3224 普通平衡树 Trie树
- bzoj 1212 L语言 DP+Trie树
- bzoj 3217: ALOEXT 替罪羊树套trie
- BZOJ[4896] Trie
- [BZOJ]4260: Codechef REBXOR 可持久化Trie
- BZOJ 3217 ALOEXT 替罪羊树套Trie树
- BZOJ 2537 [neerc2007]Language Recognition Trie树 树Hash
- (三十九)守护进程
- iphone不越狱使用ss全局代理
- android 动画
- Python使用pyserial进行串口通信
- 愚蠢的错误 Failed to connect to 127.0.0.1 port 8888 :conection refused
- BZOJ 4260 trie树
- PipedInputStream和PipedOutputStream
- 【日记】学习Android开发
- 微信公众号开发8联合ThinkPHP3
- 在线教育发展前景良好,网校系统搭建步伐加快
- 【SSH网上商城项目实战06】基于DataGrid的数据显示
- 使用OpenSCAP对CentOS6进行安全检查
- 优雅实现RecyclerView多种布局
- html5响应式餐厅美食网页模板