当前位置:网站首页>Find the maximum XOR value in the sequence given a number (01 Dictionary)
Find the maximum XOR value in the sequence given a number (01 Dictionary)
2022-06-29 17:56: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 a SCM system? What are the advantages of a supply chain management system?
- Repair of JSON parsing errors in a collection
- selenium上传文件
- QQ如何开通在线客服
- 3h精通OpenCV(六)-图像堆叠
- Openfeign use step polling strategy and weight log4j configuration of openfeign interceptor
- Prevent form resubmission based on annotations and interceptors
- What technology is an applet container? Can it help Internet of things enterprises break through the red sea?
- SRM supplier collaborative management system function introduction
- 迈动互联中标大家保险集团
猜你喜欢

How to create and delete MySQL triggers

Teach you how to install the latest version of mysql8.0 database on windows, nanny level teaching

ISO 32000-2 international standard 7.7

【WebDriver】使用AutoIt上传文件

关于日期相加减问题

Premature end of script headers 或 End of script output before headers

Opencv+YOLO-V3实现目标跟踪

What are the usage scenarios for locks in MySQL

小程序容器是什么技术?能助力物联网企业红海突围?

Analyze the implementation principle of zero copy mechanism, applicable scenarios and code implementation
随机推荐
剖析下零拷贝机制的实现原理,适用场景和代码实现
Inherit Chinese virtues, pay attention to the health of the middle-aged and the elderly, and Yurun milk powder has strong respect for the elderly
测试dble split功能执行+导入耗时shell脚本参考
字典树(随学)
Analyze the implementation principle of zero copy mechanism, applicable scenarios and code implementation
Bloom filter:
Mysql database literacy, do you really know what a database is
回文子串的最大长度(字符串哈希+二分)
Web Scraping with Beautiful Soup for Data Scientist
Industry application of smart city based on GIS 3D visualization
分布式 | 几步快速拥有读写分离
从一个被应用商店坑了的BUG说起
The soft youth under the blessing of devcloud makes education "smart" in the cloud
最受欢迎的30款开源软件
Visio annotation, annotation location
3h精通OpenCV(八)-形状检测
Can MySQL views create indexes
phpunit骚操作之静态类的部分mock
Visual studio plug-in coderush officially released v22.1 -- visual tool for optimizing debugging
【Try to Hack】Cookie和Session