当前位置:网站首页>给定一个数在序列中求最大异或值(01字典)
给定一个数在序列中求最大异或值(01字典)
2022-06-29 17:47:00 【eva_can(not)survive】
int s[MAXN];
int tri[MAXN][2],cnt;
int num[MAXN];
void init(){
memset(tri,0,sizeof(tri));
memset(num,0,sizeof(num));
cnt=1;
}
void insert(int n){
int cur=1;
for(int i=MAXBIT;i>=0;i--){
int bit=n>>i&1;
if(!tri[cur][bit]) tri[cur][bit]=++cnt;
cur=tri[cur][bit];
}
num[cur]=n;
}
int find_max(int x){
int cur=1;
for(int i=MAXBIT;i>=0;i--){
int bit=x>>i&1;
if(tri[cur][bit^1]) cur=tri[cur][bit^1];
else cur=tri[cur][bit];
}
return num[cur];
}
void _solve(){
init();
int n,m;
scanf("%d %d",&n,&m);
for(int i=1;i<=n;i++){
scanf("%d",s+i);
insert(s[i]);
}
ll k;
for(int i=1;i<=m;i++){
scanf("%d",&k);
printf("%d\n",find_max(k));
}
}边栏推荐
- 上班可以做副业
- What is the SRM system? How do I apply the SRM system?
- Two controller layer interface authentication methods
- ISO 32000-2 国际标准7.7
- Detailed introduction and Simulation of bitmap
- Visio标注、批注位置
- 使用autoIt 上传文件
- Younger sister Juan takes you to learn JDBC - 2-day dash Day1
- 3h精通OpenCV(九)-最简单的人脸检测
- MaxCompute Studio
猜你喜欢

2022春夏系列 KOREANO ESSENTIAL重塑时装生命力

Visio annotation, annotation location

VB.Net读写NFC Ntag标签源码

Parental delegation mechanism
![Fill in the next right node pointer of each node [make good use of each point - > reduce the space-time complexity as much as possible]](/img/33/bda0a898bfe3503197026d1f62e851.png)
Fill in the next right node pointer of each node [make good use of each point - > reduce the space-time complexity as much as possible]

Digital twin energy system, creating a "perspective" in the low-carbon era

How to use the chart control of the b/s development tool devextreme - customize the axis position?

Professor of Cambridge University: eating breakfast often is harmful and dangerous. - you know what

【WebDriver】使用AutoIt上传文件

How MySQL queries character set codes of tables
随机推荐
R语言ggplot2可视化:使用patchwork包(直接使用加号+)将两个ggplot2可视化结果横向组合、接着再和第三个图像横向组合起来(三幅图各占比例为50%、25%、25%)
MaxCompute字符串替换函数-replace
基于gis三维可视化的智慧城市行业运用
The R language uses the KAP function (kap.2.raters function) of epidisplay package to calculate the value of kappa statistics (total consistency, expected consistency), analyze the consistency of the
上班可以做副业
测试dble split功能执行+导入耗时shell脚本参考
Selenium file upload method
Repair of JSON parsing errors in a collection
mongoTemplate - distinct 使用
R语言dplyr包filter函数通过组合逻辑(与逻辑)过滤dataframe数据中的数据、其中一个字段的内容等于指定向量中的其中一个,并且另外一个字段值大于某一阈值
两种Controller层接口鉴权方式
R语言使用自定义函数编写深度学习线性激活函数、并可视化线性激活函数
R语言使用自定义函数编写深度学习Leaky ReLU激活函数、并可视化Leaky ReLU激活函数
Does rapid software delivery really need to be at the cost of security?
Analyze the implementation principle of zero copy mechanism, applicable scenarios and code implementation
The soft youth under the blessing of devcloud makes education "smart" in the cloud
力扣今日题-535. TinyURL 的加密与解密
小程序容器是什么技术?能助力物联网企业红海突围?
关于日期相加减问题
R语言epiDisplay包的aggregate函数将数值变量基于因子变量拆分为不同的子集,计算每个子集的汇总统计信息、aggregate.data.frame函数包含缺失值的情况下分组统计结果为NA