当前位置:网站首页>[learning notes] linear basis
[learning notes] linear basis
2022-06-28 08:14:00 【Ants looking up at the stars】
I still don't feel that I understand qwq …
Definition
Set of assumptions T T T The range of values is [ 1 , 2 n − 1 ] [1,2^n-1] [1,2n−1] .
T T T The linear basis of is T T T One of the A subset of A = { a 1 , a 2 , . . . , a n } A=\{a_1,a_2,...,a_n\} A={ a1,a2,...,an}
A A A All elements in the are mutually xor The XOR set formed , Equivalent to the set of primitive numbers T T T The elements of each other xor An XOR set formed .
It can be understood as compressing the original number set .
nature
- The XOR scheme of each element in the XOR set of linear bases only
- The highest bit of linear basis binary is different from each other
- Elements in a linear basis are exclusive or to each other , The XOR set does not change .
- The linear base XOR set size is 2 ∣ A ∣ 2^{|A|} 2∣A∣ , The number of occurrences of each element is exactly 2 n − ∣ A ∣ 2^{n-|A|} 2n−∣A∣ .
Insert
void ins(int x) {
for(int i=50;i>=0;i--) {
if(x>>i&1) {
if(a[i]) x^=a[i];
else {
a[i]=x;return;}
}
}
}
nature : about n n n A collection of numbers , Suppose the linear basis is S S S , So it's going to generate 2 ∣ S ∣ 2^{|S|} 2∣S∣ Kind of Different Exclusive or values ( An exclusive or value corresponds to a unique way ), A value will appear 2 n − ∣ S ∣ 2^{n-|S|} 2n−∣S∣ Time .
restructure
void rebuild() {
for(int i=50;i>=0;i--) {
for(int j=i-1;j>=0;j--) {
if(a[i]>>j&1) a[i]^=a[j];
}
}
for(int i=0;i<=50;i++) {
if(a[i]) p[cnt++]=a[i]
}
}
Please K Small
According to the nature 2 .
We need to transform the linear basis into each bit independent of each other .
So the query will K K K Binary split , about 1 1 1 Bit , On the corresponding linear basis on XOR .
The final answer is K Small value .
void Kth(ll K) {
K--;
if(K>=(1<<cnt)) return -1;
ll res(0);
for(int i=0;i<cnt;i++) {
if(K>>i&1) res^=p[i];
}
return res;
}
Ranking
Can't . Only ugly code .( There should be some clever way Ha ha ha )
ll qry(int x) {
ll res(0),y(0);
for(int i=30;i>=0;i--) {
if(a[i]==0) {
if((y>>i&1)>(x>>i&1)) {
break;
}
}
else {
if(x>>i&1) {
res=(res+fpow(2,(i>0)?cnt[i-1]:0,10086))%10086;
}
if((x>>i&1)!=(y>>i&1)) {
y^=a[i];
}
}
}
if(y<x) res++;
return res;
}
边栏推荐
- PC端隐藏滚动条
- App automated testing appium tutorial 2 - ADB command
- Chenglian premium products donated love materials for flood fighting and disaster relief to Yingde
- [JS] - [DFS, BFS application] - learning notes
- Devops foundation chapter Jenkins deployment (II)
- asp. Net datalist when there are multiple data displays
- Upgrade HDP spark to spark 2.4.8 without upgrading ambari
- Activity implicit jump
- Unity 获取当前物体正前方,一定角度、距离的坐标点
- 关于如何在placeholder中使用字体图标
猜你喜欢

Activity隐式跳转

Today's notes 22/1/7

Online WPS tool

Redis cluster deployment and application scenarios

App automated testing appium tutorial 2 - ADB command

设置cmd的编码为utf-8

B_ QuRT_ User_ Guide(27)

After installing NRM, the internal/validators js:124 throw new ERR_ INVALID_ ARG_ TYPE(name, ‘string‘, value)

Redis cerebral fissure

sql分析(查询截取分析做sql优化)
随机推荐
asp. Net upload image path and image name
Is it reliable to open an account by digging money? Is it safe?
Solve NPM err! Unexpected end of JSON input while parsing near
Configuring MySQL multi instance master-slave synchronization for Linux
Discussion on the application of GIS 3D system in mining industry
On the solution of insufficient swap partition
Airflow2.x distributed deployment DAG execution failure log cannot be obtained normally
B_QuRT_User_Guide(30)
B_ QuRT_ User_ Guide(27)
Do you know TCP protocol (1)?
SLAM中常用的雅克比矩阵J
【学习笔记】线性基
三角变换公式
【学习笔记】拟阵
Oracle view tablespace usage
图像翻译/Transformer:ITTR: Unpaired Image-to-Image Translation with Transformers用Transfor进行非配对图像对图像的转换
AI首席架构师8-AICA-高翔 《深入理解和实践飞桨2.0》
Devops Basics: Jenkins deployment and use (I)
【学习笔记】最短路 +生成树
How redis solves cache avalanche, breakdown and penetration problems