[BZOJ4260] Codechef REBXOR
来源:互联网 发布:节食一个月减肥 知乎 编辑:程序博客网 时间:2024/06/04 19:05
传送门
http://www.lydsy.com/JudgeOnline/problem.php?id=4260
题目大意
给定序列,求最大的
题解
xor是支持交换律的,所以我们维护xor前缀和
问题变为求
…..我是傻逼,,,,,2^28>10^9
const maxn=400005;var x,sum,dp:array[0..maxn]of longint; son:array[1..2,0..maxn*31,0..1]of longint; i,j,k:longint; n,a,tail,ans:longint;function max(a,b:longint):longint;begin if a<b then exit(b) else exit(a);end;procedure init(kind,a:longint);var i,tt,b:longint;begin tt:=0; for i:=30 downto 1 do begin if (a and (1<<(i-1)))=0 then b:=0 else b:=1; if son[kind,tt,b]=0 then begin inc(tail); son[kind,tt,b]:=tail; end; tt:=son[kind,tt,b]; end;end;function f(kind,a:longint):longint;var i,tt,b,c,anss:longint;begin tt:=0; anss:=0; for i:=30 downto 1 do begin if (a and (1<<(i-1)))=0 then b:=0 else b:=1; c:=b xor 1; if son[kind,tt,c]<>0 then begin anss:=anss+(1<<(i-1)); tt:=son[kind,tt,c]; end else begin tt:=son[kind,tt,b]; end; end; exit(anss);end;begin readln(n); sum[0]:=0; for i:=1 to n do begin read(x[i]); sum[i]:=sum[i-1] xor x[i]; end; tail:=0; for i:=1 to n do begin init(1,sum[i-1]); dp[i]:=max(dp[i-1],f(1,sum[i])); end; tail:=0; ans:=0; for i:=n downto 1 do begin init(2,sum[i]); a:=f(2,sum[i-1]); ans:=max(ans,dp[i-1]+a); end; writeln(ans);end.
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字典树
- Android 快速开发 打造万能的ListView GridView 适配器
- 创建工程运行时报错:The container 'Android Dependencies' references non existing library
- 深度学习之三---深度学习的两种主要学习方法与区别
- HDU1114 Piggy-Bank(完全背包)
- contents和contentsGravity属性
- [BZOJ4260] Codechef REBXOR
- UI基础-01-控制器概念
- php命名空间与自动加载函数一起使用
- Jekyll search组件
- 289. Game of Life
- 极光推送之服务器端向android等客户端推送实例
- STL算法库-数字运算(三)
- RH413企业安全加固 第7章 管理附加文件权限
- 题目:已知rand7() 可以产生 1~7 的7个数(均匀概率),利用rand7() 产生rand10() 1~10(均匀概率)