当前位置:网站首页>Linear basis
Linear basis
2022-06-26 13:57:00 【__ LazyCat__】
Linear base Basic template
link :#113. The greatest exclusive or and - subject - LibreOJ (loj.ac)
Given a reproducible set s , Find a proper subset , Maximize the exclusive or sum of all numbers in the true subset .
- Reproducible set s Any number in a linear basis can have an exclusive or of numbers in a linear basis .
- The exclusive or sum of any proper subset in a linear basis is not 0 .
- p i p_{i} pi It means the first one i Position as 1 And is the highest number .( Then the lower order of the time does not affect the higher order )
- Reduce the dimension of high-dimensional data during insertion .
When inserting data , To make x Exclusive or sum with a proper subset in a linear base is 0 , Indicates that... Can be synthesized x , Then judge from high to low bit by bit x , Ruodi i Position as 0 , Then this bit does not need any data XOR representation in the set ; if 1, Then check whether there is no i Whether the linear basis of bit exists , If it doesn't exist x Act as a base and exit , If it exists, it will x Low dimensional . In the end, there is no such thing as x Operate as a base , send x by 0 It means that the current linear basis can be synthesized x, No need to insert .
Answer key : Observe the topic , Find a subset to maximize the XOR sum , You just need to make the high order as 1 that will do .
//#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
const int maxn=1<<6;
ll p[maxn],n,a;
void insert(ll x)
{
for(int i=50;i>=0;i--)
{
if(x>>i&1)
{
if(!p[i]){
p[i]=x; break;}
x^=p[i];
}
}
return;
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
cin>>n;
for(int i=1;i<=n;i++)
{
cin>>a,insert(a);
}
ll ans=0;
for(int i=50;i>=1;i--)
{
ans=max(ans,ans^p[i]);
}
cout<<ans<<"\n";
return 0;
}
边栏推荐
- Generate JDE dot train
- Es sauvegarde et restauration des données par instantané
- 8.Ribbon负载均衡服务调用
- Taishan Office Technology Lecture: four cases of using bold font
- 网络远程访问的方式使用树莓派
- Teacher Li Hang's new book "machine learning methods" is on the market! Purchase link attached
- Applicable and inapplicable scenarios of mongodb series
- D check type is pointer
- 虫子 运算符重载的一个好玩的
- 去某东面试遇到并发编程问题:如何安全地中断一个正在运行的线程
猜你喜欢

hands-on-data-analysis 第三单元 模型搭建和评估

There are many contents in the widget, so it is a good scheme to support scrolling

Common operation and Principle Exploration of stream

shell脚本详细介绍(四)

Self created notes (unique in the whole network, continuously updated)

7.consul service registration and discovery

Pointer

Some conclusions about Nan

Free machine learning dataset website (6300+ dataset)
![[MySQL from introduction to mastery] [advanced part] (II) representation of MySQL directory structure and tables in the file system](/img/03/a1885e4740bbfdbdee2446e3dd81d0.png)
[MySQL from introduction to mastery] [advanced part] (II) representation of MySQL directory structure and tables in the file system
随机推荐
Taishan Office Technology Lecture: four cases of using bold font
Wechat applet magic bug - choose to replace the token instead of clearing the token, wx Getstoragesync will take the old token value instead of the new token value
7-1 range of numbers
Variable declaration of typescript
Global variable vs local variable
Aesthetic experience (episode 238) Luo Guozheng
遍历指定目录获取当前目录下指定后缀(如txt和ini)的文件名
A must for programmers, an artifact utools that can improve your work efficiency n times
Introduction to 26 papers related to CVPR 2022 document image analysis and recognition
虫子 内存管理 上
Stack, LIFO
Jenkins build prompt error: eacces: permission denied
Connection migration for DataGrid configuration
ES6:Map
Zero basics of C language lesson 7: break & continue
嵌入式virlog代码运行流程
[proteus simulation] Arduino uno key start / stop + PWM speed control DC motor speed
Thinking caused by the error < note: candidate expectations 1 argument, 0 provided >
爱可可AI前沿推介(6.26)
GEE——全球人类居住区网格数据 1975-1990-2000-2014