当前位置:网站首页>[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]);
}
边栏推荐
- SQL: common SQL commands
- Sorted out an ECS summer money saving secret, this time @ old users come and take it away
- Learn more about materialapp and common attribute parsing in fluent
- 【leetcode】81. Search rotation sort array II
- Force buckle 540 A single element in an ordered array
- The original author is out! Faker. JS has been controlled by the community..
- What is 5g industrial wireless gateway? What functions can 5g industrial wireless gateway achieve?
- Bitmap principle code record
- JVM knowledge points
- Handling of inconsistency between cursor and hinttext position in shutter textfield
猜你喜欢

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

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

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

Force buckle 540 A single element in an ordered array

Demonstration description of integrated base scheme

深圳打造全球“鸿蒙欧拉之城”将加快培育生态,优秀项目最高资助 1000 万元

66.qt quick QML Custom Calendar component (supports vertical and horizontal screens)

Recently, the weather has been extremely hot, so collect the weather data of Beijing, Shanghai, Guangzhou and Shenzhen last year, and make a visual map

How much can a job hopping increase? Today, I saw the ceiling of job hopping.

WiFi 5GHz frequency
随机推荐
【提高课】ST表解决区间最值问题【2】
Nacos 配置中心整体设计原理分析(持久化,集群,信息同步)
How much is the tuition fee of SCM training class? How long is the study time?
【c语言】动态规划---入门到起立
Yyds dry inventory compiler and compiler tools
手撕——排序
初识P4语言
[untitled]
Demonstration description of integrated base scheme
[source code analysis] NVIDIA hugectr, GPU version parameter server - (1)
Pandora IOT development board learning (HAL Library) - Experiment 2 buzzer experiment (learning notes)
office_ Delete the last page of word (the seemingly blank page)
Target free or target specific: a simple and effective zero sample position detection comparative learning method
JVM knowledge points
Go branch and loop
Playing with concurrency: what are the ways of communication between threads?
Realizing deep learning framework from zero -- Introduction to neural network
Recently, the weather has been extremely hot, so collect the weather data of Beijing, Shanghai, Guangzhou and Shenzhen last year, and make a visual map
LxC limits the number of CPUs
Qt插件之Qt Designer插件实现