bzoj4260: Codechef REBXOR
来源:互联网 发布:打车软件大公司 编辑:程序博客网 时间:2024/06/05 03:28
题意
题目自己看【不负责】
题解
异或的话上次知道了新武器—–可持久化tir
这题也是。。
对于这道题,就DP两次
正着一次,反着一次就好了
我的代码拍的时候和标程差不多快。。
然后TLE了。。。
然后FYC10s卡时过。。放一个他的代码吧
#include<cstdio>#include<cstdlib>#include<cstring>#include<iostream>#define LL long longconst int N=400005;using namespace std;struct trnode{ int c,a[2];}tr[35*N];int root[N],tot=0;LL read(){ LL x=0,f=1;char ch=getchar(); while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();} while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();} return x*f;}void add(int &x,int froot,LL k,int num){ x=++tot; tr[x]=tr[froot];tr[x].c++; if(num==-1) return; LL c=(k&(1LL<<num)); c=(c!=0); add(tr[x].a[c],tr[froot].a[c],k,num-1);}LL solve(int lroot,int rroot,LL k,int num){ if(num==-1) return 0; LL c=(k&(1LL<<num)); c=(c!=0);c^=1; int lrc=tr[tr[lroot].a[c]].c,rrc=tr[tr[rroot].a[c]].c; if(lrc==rrc) c^=1; return (c<<num)+solve(tr[lroot].a[c],tr[rroot].a[c],k,num-1);}int n;LL a[N],sum1[N],sum2[N];int main(){ n=read();a[0]=0; add(root[1],root[0],0,33); for(int i=1;i<=n;i++) { a[i+1]=read(); a[i+1]^=a[i]; add(root[i+1],root[i],a[i+1],33); } sum1[0]=-1;sum2[n+2]=-1; for(int i=2;i<=n+1;i++) sum1[i]=max(sum1[i-1],solve(root[0],root[i],a[i],33)^a[i]); for(int i=n+1;i>=2;i--) sum2[i]=max(sum2[i+1],solve(root[i-2],root[n+1],a[i],33)^a[i]); LL ans=-1; for(int i=2;i<=n;i++) ans=max(ans,sum1[i]+sum2[i+1]); printf("%lld",ans);}
阅读全文
0 0
- [BZOJ4260] Codechef REBXOR
- 【BZOJ4260】Codechef REBXOR
- bzoj4260 Codechef REBXOR
- 【bzoj4260】【Codechef REBXOR】【trie】
- bzoj4260: Codechef REBXOR
- BZOJ4260 Codechef REBXOR trie
- 【bzoj4260】Codechef REBXOR
- 【bzoj4260】 Codechef REBXOR trie树
- [BZOJ4260][字典树]Codechef REBXOR
- 4260: Codechef REBXOR trie
- bzoj 4260 Codechef REBXOR
- 4260: Codechef REBXOR
- bzoj 4260: Codechef REBXOR
- Codechef REBXOR(01Trie)
- 【BZOJ 4260】 Codechef REBXOR|trie
- bzoj 4260: Codechef REBXOR Trie
- BZOJ 4260: Codechef REBXOR|Trie树
- BZOJ 4206 Codechef REBXOR 01字典树
- es6中模块化:export和export default的区别
- windows用命令行安装git docker python nvm node
- 《方术纪异》读后感
- 初识c#---多态(方法重载,方法重写,里氏替换原则)抽象,接口
- RocketMQ : 4.1.0-incubating集群部署
- bzoj4260: Codechef REBXOR
- [编程题] 数字翻转
- AAA《深入理解mybatis原理》 MyBatis的架构设计以及实例分析
- bzoj 1907(树形dp)
- Scrapy命令行工具
- Threejs开发笔记之十纹理
- vector的定义
- Java知识图谱
- java.util包详解