当前位置:网站首页>[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]);
}
边栏推荐
- 整理了一份ECS夏日省钱秘籍,这次@老用户快来领走
- Installation and use of blue lake
- C language: examples of logical operation and judgment selection structure
- [untitled]
- Wechat applet pull-down loading more waterfall flow loading
- Cloud service selection of enterprises: comparative analysis of SaaS, PAAS and IAAs
- 如何解决在editor模式下 无法删除物体的问题
- 《西线无战事》我们才刚开始热爱生活,却不得不对一切开炮
- Playing with concurrency: what are the ways of communication between threads?
- 2022-07-01: at the annual meeting of a company, everyone is going to play a game of giving bonuses. There are a total of N employees. Each employee has construction points and trouble points. They nee
猜你喜欢

树莓派GPIO引脚控制红绿灯与轰鸣器

文档声明与字符编码

How much is the tuition fee of SCM training class? How long is the study time?

手撕——排序
![[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)

Li Kou interview question 02.08 Loop detection

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

Demonstration description of integrated base scheme

Go语言介绍
![[C language] Dynamic Planning --- from entry to standing up](/img/7e/29482c8f3970bb1a40240e975ef97f.png)
[C language] Dynamic Planning --- from entry to standing up
随机推荐
Today's plan: February 15, 2022
XSS prevention
Mysql中常见的锁
云服务器的安全设置常识
Demonstration description of integrated base scheme
LxC limits the number of CPUs
Play with concurrency: draw a thread state transition diagram
office_ Delete the last page of word (the seemingly blank page)
FAQ | FAQ for building applications for large screen devices
The confusion I encountered when learning stm32
Which is better, industrial intelligent gateway or edge computing gateway? How to choose the right one?
66.qt quick QML Custom Calendar component (supports vertical and horizontal screens)
WiFi 5GHz frequency
go 分支与循环
A summary of common interview questions in 2022, including 25 technology stacks, has helped me successfully get an offer from Tencent
Dare to go out for an interview without learning some distributed technology?
Introduction to vmware workstation and vSphere
2022-07-01:某公司年会上,大家要玩一食发奖金游戏,一共有n个员工, 每个员工都有建设积分和捣乱积分, 他们需要排成一队,在队伍最前面的一定是老板,老板也有建设积分和捣乱积分, 排好队后,所有
WPViewPDF Delphi 和 .NET 的 PDF 查看组件
藍湖的安裝及使用