当前位置:网站首页>Array proof during st table preprocessing
Array proof during st table preprocessing
2022-07-07 06:18:00 【Harris-H】
ST Array proof during table preprocessing
a i = x ( 2 x ≤ i < 2 x + 1 ) a_i=x(2^x\le i< 2^{x+1}) ai=x(2x≤i<2x+1)
Recurrence equation : a i = a i 2 + 1 a_i=a_{\small\dfrac{i}{2}}+1 ai=a2i+1
prove :
a i 2 = x a_{\dfrac{i}{2}}=x a2i=x
2 x ≤ i 2 < 2 x + 1 2^x\le \dfrac{i}{2}<2^{x+1} 2x≤2i<2x+1
∴ 2 x + 1 ≤ i < 2 x + 2 \therefore 2^{x+1}\le i<2^{x+2} ∴2x+1≤i<2x+2
2 × i 2 ≤ i ≤ 2 x + 2 2\times \dfrac{i}{2}\le i\le2^{x+2} 2×2i≤i≤2x+2
Certificate completion .
So you can O ( n ) O(n) O(n) Preprocessing logarithmic array .
then O ( 1 ) O(1) O(1) Realize interval query .
Attached with one RMQ.
#define il inline
struct RMQ{
int f[N][20],b[N];//pay attention init f[i][0]
il void init(int n){
for(int i=2;i<=n;i++) //pre deal with
b[i]=b[i>>1]+1; // Attention from 2 Start
for(int j=1;j<=b[n];j++)
for(int i=1;i+(1<<j)-1<=n;i++)
f[i][j]=max(f[i][j-1],f[i+(1<<j-1)][j-1]);
}
il int que(int l,int r){
int x=b[r-l+1];
return max(f[l][x],f[r-(1<<x)+1][x]);
}
}rm;
边栏推荐
- Rk3399 platform development series explanation (WiFi) 5.53, hostapd (WiFi AP mode) configuration file description
- Red hat install kernel header file
- CloudCompare-点对选取
- You don't know the complete collection of recruitment slang of Internet companies
- JVM monitoring and diagnostic tools - command line
- 老板总问我进展,是不信任我吗?(你觉得呢)
- 牙齿干细胞的存储问题(未完待续)
- Experience of Niuke SQL
- 当我们谈论不可变基础设施时,我们在谈论什么
- 3531. Huffman tree
猜你喜欢
C. colonne Swapping [tri + Simulation]
Deep clustering: joint optimization of depth representation learning and clustering
Jmeter自带函数不够用?不如自己动手开发一个
tkinter窗口选择pcd文件并显示点云(open3d)
If you don't know these four caching modes, dare you say you understand caching?
Find duplicate email addresses
Financial risk control practice - decision tree rule mining template
Dc-7 target
Chain storage of stack
[SQL practice] a SQL statistics of epidemic distribution across the country
随机推荐
云加速,帮助您有效解决攻击问题!
高并发大流量秒杀方案思路
[FPGA] EEPROM based on I2C
Change the original style of UI components
[FPGA tutorial case 13] design and implementation of CIC filter based on vivado core
职场经历反馈给初入职场的程序员
安装mongodb数据库
Subghz, lorawan, Nb IOT, Internet of things
3531. Huffman tree
laravel 使用腾讯云 COS5全教程
Bbox regression loss function in target detection -l2, smooth L1, IOU, giou, Diou, ciou, focal eiou, alpha IOU, Siou
Solve pod install error: FFI is an incompatible architecture
软件测试的几个关键步骤,你需要知道
cf:C. Column Swapping【排序 + 模拟】
@Detailed differences between pathvariable and @requestparam
生活中的开销,怎么记账合适
Check Point:企业部署零信任网络(ZTNA)的核心要素
A very good JVM interview question article (74 questions and answers)
JVM监控及诊断工具-命令行篇
When we talk about immutable infrastructure, what are we talking about