当前位置:网站首页>【提高课】ST表解决区间最值问题【2】
【提高课】ST表解决区间最值问题【2】
2022-07-02 04:10:00 【ZhgDgE】
【提高课】ST表解决区间最值问题
这是之前写的,现在重新整理了模板,可以返回最小值的下标。
ST 表求区间最小值:
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]);
}
边栏推荐
- Qt插件之Qt Designer插件实现
- Wpviewpdf Delphi and Net PDF viewing component
- 【人员密度检测】基于形态学处理和GRNN网络的人员密度检测matlab仿真
- Demonstration description of integrated base scheme
- C语言:逻辑运算和判断选择结构例题
- Fluent icon demo
- uni-app - 实现获取手机验证码倒计时 60 秒(手机号+验证码登录功能)
- Force buckle 540 A single element in an ordered array
- go 语言命名规范
- LxC limits the number of CPUs
猜你喜欢

Play with concurrency: what's the use of interruptedexception?

How to model noise data? Hong Kong Baptist University's latest review paper on "label noise representation learning" comprehensively expounds the data, objective function and optimization strategy of

First acquaintance with P4 language

云服务器的安全设置常识

软件测试人的第一个实战项目:web端(视频教程+文档+用例库)

Nacos 配置中心整体设计原理分析(持久化,集群,信息同步)

Force buckle 540 A single element in an ordered array

Fluent icon demo

MySQL error: expression 1 of select list is not in group by claim and contains nonaggre

Homework in Chapter 3 of slam course of dark blue vision -- derivative application of T6 common functions
随机推荐
powershell_ View PowerShell function source code (environment variable / alias) / take function as parameter
Sorted out an ECS summer money saving secret, this time @ old users come and take it away
云服务器的安全设置常识
Pytorch---使用Pytorch进行鸟类的预测
Dare to go out for an interview without learning some distributed technology?
【力扣刷题】15.三数之和(双指针);17.电话号码的字母组合(递归回溯)
Typescript practice for SAP ui5
[JS -- map string]
Uni app - realize the countdown of 60 seconds to obtain the mobile verification code (mobile number + verification code login function)
Cloud service selection of enterprises: comparative analysis of SaaS, PAAS and IAAs
【无线图传】基于FPGA的简易无线图像传输系统verilog开发,matlab辅助验证
Okcc why is cloud call center better than traditional call center?
Learn more about materialapp and common attribute parsing in fluent
[live broadcast review] the first 8 live broadcasts of battle code Pioneer have come to a perfect end. Please look forward to the next one!
【leetcode】81. Search rotation sort array II
Jetpack's livedata extension mediatorlivedata
Document declaration and character encoding
Raspberry pie GPIO pin controls traffic light and buzzer
Spring recruitment of Internet enterprises: Kwai meituan has expanded the most, and the annual salary of technical posts is up to nearly 400000
Wechat applet pull-down loading more waterfall flow loading