当前位置:网站首页>【提高课】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]);
}
边栏推荐
- Welcome the winter vacation multi school league game 2 partial solution (B, C, D, F, G, H)
- Pytorch---使用Pytorch进行鸟类的预测
- Homework in Chapter 3 of slam course of dark blue vision -- derivative application of T6 common functions
- Which insurance company has a better product of anti-cancer insurance?
- 初识P4语言
- Wechat applet pull-down loading more waterfall flow loading
- 蓝湖的安装及使用
- PR zero foundation introductory guide note 2
- 【c语言】动态规划---入门到起立
- LxC limits the number of CPUs
猜你喜欢
Analysis of the overall design principle of Nacos configuration center (persistence, clustering, information synchronization)
FAQ | FAQ for building applications for large screen devices
"No war on the Western Front" we just began to love life, but we had to shoot at everything
Set vscode. When double clicking, the selected string includes the $symbol - convenient for PHP operation
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
Yolov5网络修改教程(将backbone修改为EfficientNet、MobileNet3、RegNet等)
[personal notes] PHP common functions - custom functions
Learn more about materialapp and common attribute parsing in fluent
Www 2022 | rethinking the knowledge map completion of graph convolution network
Force buckle 540 A single element in an ordered array
随机推荐
Play with concurrency: what's the use of interruptedexception?
5g era is coming in an all-round way, talking about the past and present life of mobile communication
BiShe cinema ticket purchasing system based on SSM
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
[JS event -- event flow]
How to solve the code error when storing array data into the database
BGP experiment the next day
SQL:常用的 SQL 命令
Pytorch---使用Pytorch进行鸟类的预测
2022-07-01:某公司年会上,大家要玩一食发奖金游戏,一共有n个员工, 每个员工都有建设积分和捣乱积分, 他们需要排成一队,在队伍最前面的一定是老板,老板也有建设积分和捣乱积分, 排好队后,所有
First acquaintance with P4 language
u本位合约爆仓清算解决方案建议
初识P4语言
Use of go package
Lost a few hairs, and finally learned - graph traversal -dfs and BFS
Is the product of cancer prevention medical insurance safe?
[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!
手撕——排序
Which insurance company has a better product of anti-cancer insurance?
LCM of Spreadtrum platform rotates 180 °