当前位置:网站首页>[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]);
}
边栏推荐
- Which is better, industrial intelligent gateway or edge computing gateway? How to choose the right one?
- Handling of inconsistency between cursor and hinttext position in shutter textfield
- Go function
- Pytorch---使用Pytorch进行图像定位
- 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语言】基础篇学习笔记
- Www2022 | know your way back: self training method of graph neural network under distribution and migration
- Use of go package
- Use a mask to restrict the input of the qlineedit control
- Wechat applet pull-down loading more waterfall flow loading
猜你喜欢
[wireless image transmission] FPGA based simple wireless image transmission system Verilog development, matlab assisted verification
Target free or target specific: a simple and effective zero sample position detection comparative learning method
Learn more about materialapp and common attribute parsing in fluent
Use of go package
[JS event -- event flow]
The confusion I encountered when learning stm32
《动手学深度学习》(二)-- 多层感知机
66.qt quick QML Custom Calendar component (supports vertical and horizontal screens)
Pytoch --- use pytoch to predict birds
Go language introduction
随机推荐
Installation et utilisation du lac bleu
WiFi 5GHz frequency
Yyds dry inventory compiler and compiler tools
A thorough understanding of the development of scorecards - the determination of Y (Vintage analysis, rolling rate analysis, etc.)
Three years of experience in Android development interview (I regret that I didn't get n+1, Android bottom development tutorial
千亿市场规模医疗美容行业的水究竟有多浑?
《动手学深度学习》(二)-- 多层感知机
【c语言】动态规划---入门到起立
BiShe cinema ticket purchasing system based on SSM
Raspberry pie GPIO pin controls traffic light and buzzer
【c语言】基础篇学习笔记
Realizing deep learning framework from zero -- Introduction to neural network
Dare to go out for an interview without learning some distributed technology?
[JS event -- event flow]
Thinkphp6 limit interface access frequency
Pandora IOT development board learning (HAL Library) - Experiment 2 buzzer experiment (learning notes)
SQL:常用的 SQL 命令
Lei Jun wrote a blog when he was a programmer. It's awesome
Go language introduction
SQL: common SQL commands