当前位置:网站首页>St table learning
St table learning
2022-06-13 11:02:00 【I can screw the bottle cap when I am born again】
ST The application of tables is to solve RMQ problem , Pretreatment construction ST The time complexity of the table is O(nlog n), In general, the solution of seeking interval extremum can also be maintained gcd The problem of , Advanced application is to find the maximum number of times a number appears in an interval , Count times .
The basic principles can be found in this article ++++++++++++++++++++++++++++++++++
ST Table preprocessing
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
const int N = 5e4+10;
int f[N][20],a[N],lg[N];
int n;
void init ()
{
for (int i=1;i<n;i++)
{
f[i][0] = a[i];
if (i!=1) lg[i] = lg[i>>1]+1;
}
for (int j=1;j<=lg[n];j++)
{
for (int i=1;i<=n-(1<<j)+1;i++)
{
f[i][j] = max(f[i][j-1],f[i+(1<<(j-1))][j-1]);
}
}
}
Query operation
int query(int x, int y)
{
int t = lg(y-x);
int a = f[x][t];
int b = f[y - (1 << t) + 1][t];
return max(a,b);
}
Find the maximum number of times a number appears in the interval , Count times .
Example explanation -----------------------------------
Later done cf , Found a st Table questions , yes Codeforces #736 div2 Of D topic
Title link here +++++++++++++
Topic description

blank
B There is a senior video explanation at the station
Video link +++++++++++++++++++++++++++++++++++++++++++++
边栏推荐
猜你喜欢

状态压缩DP例题(旅行商问题和填矩形问题)

ue5 小知识点 geometry script modeling

Talk about MySQL indexing mechanism

View the default MySQL password in the pagoda

Ue5 random point in bounding boxf from stream

终于,月入 20000 !!

Chapter VII document management

Ue5 small knowledge points geometry script modeling

Brief introduction to memory structure of virtual machine

什么是400G以太网?
随机推荐
Go zero microservice Practice Series (III. API definition and table structure design)
Pagoda add a website: PHP project
Advanced technology management - what management tools can managers use
Ubuntu installs MySQL compressed package for future reference
Read pgstat [this time Gauss is not a mathematician]
音视频技术开发周刊 | 249
数据库系统概念(第十七章)
[elm classification] data classification based on particle swarm optimization convolution neural network CNN combined with limit learning machine elm with matlab code
2022甘肃省安全员C证上岗证题目及在线模拟考试
终于,月入 20000 !!
Understand an article: Spark operation mode
Ue5 small knowledge points geometry script modeling
Vivo large scale kubernetes cluster automation operation and maintenance practice
C file package and download
Similarities and differences between decoration mode and agency mode
About instruction set bits and instruction architecture bits
宝塔添加一个网站:PHP项目
View the default MySQL password in the pagoda
微众银行OSPO建设之路:如何通过OSPO的建设推动企业开源?
[cloud enjoying freshness] community weekly · vol.66- Huawei partners and Developers Conference 2022 wonderful agenda announcement