当前位置:网站首页>[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]);
}
边栏推荐
- 【c语言】动态规划---入门到起立
- Pytorch---使用Pytorch进行鸟类的预测
- First acquaintance with P4 language
- MySQL error: expression 1 of select list is not in group by claim and contains nonaggre
- Installation and use of blue lake
- Nacos 配置中心整体设计原理分析(持久化,集群,信息同步)
- uni-app - 实现获取手机验证码倒计时 60 秒(手机号+验证码登录功能)
- 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
- Dare to go out for an interview without learning some distributed technology?
- PR zero foundation introductory guide note 2
猜你喜欢
![[tips] use Matlab GUI to read files in dialog mode](/img/51/6d6051836bfc9caa957d0275245bd3.png)
[tips] use Matlab GUI to read files in dialog mode

Pytorch---使用Pytorch进行图像定位
![[source code analysis] NVIDIA hugectr, GPU version parameter server - (1)](/img/e3/fc2e78dc1e3e3cacbd1a389c82d33e.jpg)
[source code analysis] NVIDIA hugectr, GPU version parameter server - (1)

C language: examples of logical operation and judgment selection structure

Websites that it people often visit

Delete the code you wrote? Sentenced to 10 months!

Sword finger offer II 006 Sort the sum of two numbers in the array

Play with concurrency: draw a thread state transition diagram

Spring recruitment of Internet enterprises: Kwai meituan has expanded the most, and the annual salary of technical posts is up to nearly 400000

Wpviewpdf Delphi and Net PDF viewing component
随机推荐
[untitled]
Hand tear - sort
PIP installation of third-party libraries
Play with concurrency: draw a thread state transition diagram
【提高课】ST表解决区间最值问题【2】
Fingertips life Chapter 4 modules and packages
Analysis of the overall design principle of Nacos configuration center (persistence, clustering, information synchronization)
The first practical project of software tester: web side (video tutorial + document + use case library)
千亿市场规模医疗美容行业的水究竟有多浑?
Wechat applet pull-down loading more waterfall flow loading
文档声明与字符编码
Pytoch --- use pytoch to predict birds
Opencv learning example code 3.2.4 LUT
手撕——排序
WPViewPDF Delphi 和 .NET 的 PDF 查看组件
How much is the tuition fee of SCM training class? How long is the study time?
Microsoft Research Institute's new book "Fundamentals of data science", 479 Pages pdf
Uni app - realize the countdown of 60 seconds to obtain the mobile verification code (mobile number + verification code login function)
go 包的使用
《西线无战事》我们才刚开始热爱生活,却不得不对一切开炮