当前位置:网站首页>[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;
}
边栏推荐
- About using font icons in placeholder
- 【学习笔记】最短路 +生成树
- js运算符的优先级
- ROS notes (08) - definition and use of service data
- Unity - use of API related to Pico development input system ---c
- B_QuRT_User_Guide(30)
- Installing MySQL under Linux
- How to choose an account opening broker? Is it safe to open an account online?
- Eslint syntax monitoring off
- Children's unit of 2022 Paris fashion week ended successfully at Wuhan station on June 19
猜你喜欢

安装nrm后,使用nrm命令报错internal/validators.js:124 throw new ERR_INVALID_ARG_TYPE(name, ‘string‘, value)

Doris学习笔记之介绍、编译安装与部署

B_ QuRT_ User_ Guide(27)

Activity implicit jump

Trigonometric transformation formula

你了解TCP协议吗(二)?

Usage record of Xintang nuc980: self made development board (based on nuc980dk61yc)

匿名页的反向映射

ROS 笔记(08)— 服务数据的定义与使用

The solution of "user account control to continue, please enter administrator user name and password" appears in win10 Professional Edition
随机推荐
How to choose an account opening broker? Is it safe to open an account online?
About using font icons in placeholder
安装nrm后,使用nrm命令报错internal/validators.js:124 throw new ERR_INVALID_ARG_TYPE(name, ‘string‘, value)
Soft exam -- software designer -- afternoon question data flow diagram DFD
The RAC cannot connect to the database normally after modifying the scan IP. The ora-12514 problem is handled
关于如何在placeholder中使用字体图标
js运算符的优先级
小艺人黄鑫洋受邀参加巴黎时装周儿童单元武汉站
B_QuRT_User_Guide(27)
Study notes 22/1/11
The preliminary round of the sixth season of 2022 perfect children's model Foshan competition area came to a successful conclusion
How to use redis to solve concurrency problems
Is it reliable for securities companies to register and open accounts? Is it safe?
Introduction, compilation, installation and deployment of Doris learning notes
npm清理缓存
【学习笔记】拟阵
Usage record of Xintang nuc980: self made development board (based on nuc980dk61yc)
探讨gis三维系统在矿山行业中的应用
你了解TCP协议吗(二)?
新唐NUC980使用记录:自制开发板(基于NUC980DK61YC)