当前位置:网站首页>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;
边栏推荐
- [cloud native] what is the microservice architecture?
- VScode进行代码补全
- Apple CMS V10 template /mxone Pro adaptive film and television website template
- 【FPGA教程案例14】基于vivado核的FIR滤波器设计与实现
- Sequential storage of stacks
- Go language learning notes - Gorm use - native SQL, named parameters, rows, tosql | web framework gin (IX)
- @pathvariable 和 @Requestparam的详细区别
- 一个简单的代数问题的求解
- The boss always asks me about my progress. Don't you trust me? (what do you think)
- Go语学习笔记 - gorm使用 - 原生sql、命名参数、Rows、ToSQL | Web框架Gin(九)
猜你喜欢

yarn入门(一篇就够了)

Find duplicate email addresses

Peripheral driver library development notes 43: GPIO simulation SPI driver

JVM命令之 jstat:查看JVM统计信息

Introduction to the extension implementation of SAP Spartacus checkout process

The solution of a simple algebraic problem

基于ADAU1452的DSP及DAC音频失真分析

Jmeter自带函数不够用?不如自己动手开发一个

为不同类型设备构建应用的三大更新 | 2022 I/O 重点回顾

Go language learning notes - Gorm use - native SQL, named parameters, rows, tosql | web framework gin (IX)
随机推荐
深度聚类:将深度表示学习和聚类联合优化
Introduction to yarn (one article is enough)
Dc-7 target
K8s running Oracle
Database notes 04
Storage of dental stem cells (to be continued)
CMD permanently delete specified folders and files
可极大提升编程思想与能力的书有哪些?
3531. Huffman tree
JVM command - jmap: export memory image file & memory usage
JVM命令之 jinfo:实时查看和修改JVM配置参数
Jcmd of JVM command: multifunctional command line
Qt多线程的多种方法之一 QThread
Loss function and positive and negative sample allocation in target detection: retinanet and focal loss
go-microservice-simple(2) go-Probuffer
JVM命令之 jstat:查看JVM統計信息
3531. 哈夫曼树
Go language learning notes - Gorm use - Gorm processing errors | web framework gin (10)
How to keep accounts of expenses in life
Cf:c. column swapping [sort + simulate]