当前位置:网站首页>[improvement class] st table to solve the interval maximum value problem [2]
[improvement class] st table to solve the interval maximum value problem [2]
2022-07-02 04:16:00 【ZhgDgE】
【 Improvement course 】ST Table solves the interval maximum problem
This was written before , Now rearrange the template , The subscript of the minimum value can be returned .
ST Table calculation of interval minimum value :
struct st_pair{
int w, idx;
bool operator < (const st_pair & x) const{
return w < x.w;
}
};
st_pair f[N][LG];
void init(){
rep(j, 0, LG - 1){
for(int i = 1; i + (1 << j) - 1 <= n; i ++ ){
if(!j) f[i][j] = {
a[i], i};
else f[i][j] = min(f[i][j - 1], f[i + (1 << j - 1)][j - 1]);
}
}
}
st_pair query(int l, int r){
int k = __lg(r - l + 1);
return min(f[l][k], f[r - (1 << k) + 1][k]);
}
边栏推荐
- [JS event -- event flow]
- Delete the code you wrote? Sentenced to 10 months!
- Which product of anti-cancer insurance is better?
- 66.qt quick-qml自定义日历组件(支持竖屏和横屏)
- Shenzhen will speed up the cultivation of ecology to build a global "Hongmeng Oula city", with a maximum subsidy of 10million yuan for excellent projects
- 【c语言】基础篇学习笔记
- A thorough understanding of the development of scorecards - the determination of Y (Vintage analysis, rolling rate analysis, etc.)
- 集成底座方案演示说明
- Pandora IOT development board learning (RT thread) - Experiment 1 LED flashing experiment (learning notes)
- Go语言介绍
猜你喜欢
随机推荐
Today's plan: February 15, 2022
Wechat applet - realize the countdown of 60 seconds to obtain the mobile verification code (mobile number + verification code login function)
Pandora IOT development board learning (RT thread) - Experiment 1 LED flashing experiment (learning notes)
Yolov5 network modification tutorial (modify the backbone to efficientnet, mobilenet3, regnet, etc.)
Use a mask to restrict the input of the qlineedit control
微信小程序 - 实现获取手机验证码倒计时 60 秒(手机号+验证码登录功能)
向数据库中存入数组数据,代码出错怎么解决
Monkey测试
Feature Engineering: summary of common feature transformation methods
MySQL error: expression 1 of select list is not in group by claim and contains nonaggre
Analysis of the overall design principle of Nacos configuration center (persistence, clustering, information synchronization)
BGP experiment the next day
SQL: common SQL commands
Bitmap principle code record
Yolov5网络修改教程(将backbone修改为EfficientNet、MobileNet3、RegNet等)
[JS -- map string]
Which product of anti-cancer insurance is better?
66.qt quick QML Custom Calendar component (supports vertical and horizontal screens)
Sword finger offer II 006 Sort the sum of two numbers in the array
Hand tear - sort



![[JS event -- event flow]](/img/fe/199890b082845f68b65f25056e6f29.jpg)





