当前位置:网站首页>【提高课】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]);
}
边栏推荐
- PR zero foundation introductory guide note 2
- Target free or target specific: a simple and effective zero sample position detection comparative learning method
- Cloud service selection of enterprises: comparative analysis of SaaS, PAAS and IAAs
- 《西线无战事》我们才刚开始热爱生活,却不得不对一切开炮
- Uni app - realize the countdown of 60 seconds to obtain the mobile verification code (mobile number + verification code login function)
- Visual slam Lecture 3 -- Lie groups and Lie Algebras
- 10 minutes to understand CMS garbage collector in JVM
- [untitled]
- Go language naming specification
- go 分支与循环
猜你喜欢

Force buckle 540 A single element in an ordered array

Influence of air resistance on the trajectory of table tennis
![[Li Kou brush questions] 15 Sum of three numbers (double pointer); 17. Letter combination of phone number (recursive backtracking)](/img/5e/81e613370c808c63665c14298f9a39.png)
[Li Kou brush questions] 15 Sum of three numbers (double pointer); 17. Letter combination of phone number (recursive backtracking)

C语言:逻辑运算和判断选择结构例题

Set vscode. When double clicking, the selected string includes the $symbol - convenient for PHP operation

Jetpack's livedata extension mediatorlivedata

Li Kou interview question 02.08 Loop detection

The first practical project of software tester: web side (video tutorial + document + use case library)

Www2022 | know your way back: self training method of graph neural network under distribution and migration

Which is better, industrial intelligent gateway or edge computing gateway? How to choose the right one?
随机推荐
Okcc why is cloud call center better than traditional call center?
Dare to go out for an interview without learning some distributed technology?
okcc为什么云呼叫中心比传统呼叫中心更好?
Pandora IOT development board learning (HAL Library) - Experiment 2 buzzer experiment (learning notes)
Fingertips life Chapter 4 modules and packages
Pytorch---使用Pytorch实现U-Net进行语义分割
66.qt quick-qml自定义日历组件(支持竖屏和横屏)
Suggestions on settlement solution of u standard contract position explosion
如何解决在editor模式下 无法删除物体的问题
[tips] use Matlab GUI to read files in dialog mode
regular expression
go 函数
Target free or target specific: a simple and effective zero sample position detection comparative learning method
Wechat applet pull-down loading more waterfall flow loading
整理了一份ECS夏日省钱秘籍,这次@老用户快来领走
Play with concurrency: draw a thread state transition diagram
Hands on deep learning (II) -- multi layer perceptron
[source code analysis] NVIDIA hugectr, GPU version parameter server - (1)
Go branch and loop
毕设-基于SSM电影院购票系统