当前位置:网站首页>[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;
}
边栏推荐
- Redis persistence problem and final solution
- Prometheus deployment alarm docking QQ mailbox
- 安装nrm后,使用nrm命令报错internal/validators.js:124 throw new ERR_INVALID_ARG_TYPE(name, ‘string‘, value)
- Host is not allowed to connect to this MySQL server
- Today's notes 22/1/7
- sql主从复制搭建
- Introduction to kubernetes (I)
- nlp序列完全可以模拟人脑智能
- Oracle RAC -- understanding of VIP
- B_QuRT_User_Guide(28)
猜你喜欢

Software testing and quality final review

B_ QuRT_ User_ Guide(28)

Unity gets the coordinate point in front of the current object at a certain angle and distance

SQL Master slave Replication Build

Host is not allowed to connect to this MySQL server

MySQL row format parsing

Little artist huangxinyang was invited to participate in the Wuhan station of children's unit of Paris Fashion Week

ROS notes (08) - definition and use of service data

你了解TCP协议吗(一)?

Airflow2.1.1 ultra detailed installation document
随机推荐
【学习笔记】模拟
城联优品向英德捐赠抗洪救灾爱心物资
11grac turn off archive log
About ASM disk space full, clean up ASM disk
Unity - use of API related to Pico development input system ---c
After installing NRM, the internal/validators js:124 throw new ERR_ INVALID_ ARG_ TYPE(name, ‘string‘, value)
js运算符的优先级
On the solution of insufficient swap partition
Explanation and application of instr() function in Oracle
MySQL installation and environment variable configuration
Host is not allowed to connect to this MySQL server
Uvcgan: unt vision transformer cycle-consistent Gan for unpropared image-to-image translation
Online WPS tool
Prometheus + grafana + MySQL master-slave replication + host monitoring
Prometheus service discovery
Is it reliable for flush to register and open an account? Is it safe?
Unity gets the coordinate point in front of the current object at a certain angle and distance
小艺人黄鑫洋受邀参加巴黎时装周儿童单元武汉站
Usage record of Xintang nuc980: self made development board (based on nuc980dk61yc)
sql主从复制搭建