当前位置:网站首页>[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;
}
边栏推荐
- Is it reliable for securities companies to register and open accounts? Is it safe?
- MySQL installation and environment variable configuration
- Discussion on the application of GIS 3D system in mining industry
- npm清理缓存
- Airflow2.x distributed deployment DAG execution failure log cannot be obtained normally
- Resolution of Rac grid failure to start after server restart
- Redis persistence problem and final solution
- MySQL implements transaction persistence using redo logs
- Ambari (IX) --- use expect to realize no interaction in ambri server setup phase (valid for personal test)
- asp. Net error "/" server error in the application. String or binary data would be truncated. The statement...
猜你喜欢

Soft test -- software designer -- database design of afternoon questions

MySQL tablespace parsing

Ambari (VII) --- ambari integrated hue4.2 document (valid for personal test)

ROS 笔记(09)— 参数的查询和设置

Idea package together, using compact middle packages to solve &

Introduction to Devops Basics

Airflow2 configuration windows azure SSO details based on oauth2 protocol

Introduction to kubernetes (I)

Devops Basics: Jenkins deployment and use (I)

Configuring multiple instances of MySQL under Linux
随机推荐
The preliminary round of the sixth season of 2022 perfect children's model Foshan competition area came to a successful conclusion
About using font icons in placeholder
软件测试与质量期末复习
[shangpinhui] project notes
挖财注册开户靠谱吗?安全吗?
Prometheus deployment alarm docking QQ mailbox
SOC timer and interrupt configuration
B_QuRT_User_Guide(27)
Activity隐式跳转
Online WPS tool
Airflow2.1.1 summary of the pits stepped on in actual combat!!
Soft exam -- software designer -- afternoon question data flow diagram DFD
你了解TCP协议吗(一)?
2022第六季完美童模 佛山赛区 初赛圆满落幕
AI首席架构师8-AICA-高翔 《深入理解和实践飞桨2.0》
Usage record of Xintang nuc980: self made development board (based on nuc980dk61yc)
Unity - Pico开发 输入系统等相关API的使用---C#篇
Jenkins' common build trigger and hook services (V)
Devops foundation chapter Jenkins deployment (II)
Helloword routine for ROS