博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
bzoj4260 Codechef REBXOR
阅读量:4365 次
发布时间:2019-06-07

本文共 1002 字,大约阅读时间需要 3 分钟。

题目描述:

 题解:

Trie树。

从左向右扫一遍,然后从右向左扫一遍。

代码:

#include
#include
#include
using namespace std;#define N 400050#define M 31*Ninline int rd(){ int f=1,c=0;char ch=getchar(); while(ch<'0'||ch>'9'){
if(ch=='-')f=-1;ch=getchar();} while(ch>='0'&&ch<='9'){c=10*c+ch-'0';ch=getchar();} return f*c;}int n,p[N];int l[N],r[N];struct Trie{ int ch[M][2],siz[M],tot; void insert(int x) { int u=0; for(int i=29;i>=0;i--) { int k = (x>>i)&1; if(!ch[u][k])ch[u][k]=++tot; u=ch[u][k];siz[u]++; } } int query(int x) { int u = 0,ret = 0; for(int i=29;i>=0;i--) { int k = (x>>i)&1; if(siz[ch[u][!k]]) { ret|=(1<
=1;i--) { r[i]=max(r[i+1],tr.query(p[i])); tr.insert(p[i]); } int ans = 0; for(int i=1;i

 

转载于:https://www.cnblogs.com/LiGuanlin1124/p/10024048.html

你可能感兴趣的文章
Linux命令
查看>>
unicode ascii 互转 函数 C实现 MultiByteToWideChar/WideCharToMultiByte 详解
查看>>
大三第一学期实验报告
查看>>
mysql远程链接
查看>>
nginx location配置
查看>>
Easy Install详细参数
查看>>
选课系统
查看>>
最简实例演示asp.net5中用户认证和授权(2)
查看>>
ubuntu rhythmbox乱码解决方法
查看>>
LeetCode题解之Univalued Binary Tree
查看>>
线程池学习研究-(自实现)2
查看>>
ubuntu下安装新字体
查看>>
Django连接MySQL数据库
查看>>
漫游Kafka入门篇之简单介绍(1)
查看>>
redis学习之旅-初识Redis
查看>>
WinForm 小程序 NotePad
查看>>
JSTL 核心标签库 使用
查看>>
Redis总结(四)Redis 的持久化(转载)
查看>>
About_Return
查看>>
10.24给TA的话
查看>>