当前位置:网站首页>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 +++++++++++++++++++++++++++++++++++++++++++++
边栏推荐
- 乘法逆元作用
- 第七章 文件管理作业
- MySQL transaction isolation level and mvcc
- Full stack development practice | integrated development of SSM framework
- JGR-A | 南京大学黄安宁团队揭示高原湖泊山地影响极端降水的动力-热力机制
- 2022 tailings recurrent training question bank and simulated examination
- The first laravel workflow engine released the official version of v1.0
- ue5 小知识点 random point in Bounding Boxf From Stream
- Go zero microservice Practice Series (III. API definition and table structure design)
- 报告录屏+PPT 傅云飞-喜马拉雅山脉南坡云降水特征研究
猜你喜欢
[elm classification] data classification based on particle swarm optimization convolution neural network CNN combined with limit learning machine elm with matlab code
ue5 小知识点 geometry script modeling
Talk about MySQL indexing mechanism
vivo大规模 Kubernetes 集群自动化运维实践
Vivo large scale kubernetes cluster automation operation and maintenance practice
Actual combat analysis of malicious code lab05-01
Brief description of redo logs and undo logs in MySQL
Database learning notes (Chapter 16)
为发泄对上司不满,百度95后程序员删库被判9个月
数据库系统概念(第十七章)
随机推荐
恶意代码实战分析Lab05-01
2021CCPC网络赛榜单
Record several interesting XSS vulnerability discoveries
乘法逆元作用
JGR-A | 南京大学黄安宁团队揭示高原湖泊山地影响极端降水的动力-热力机制
2022年劳务员-通用基础(劳务员)上岗证题目及答案
Euler function and finding Euler function by linear sieve
View the default MySQL password in the pagoda
我们用了一个周末,将 370 万行代码迁移到了 TypeScript
很妙的贪心(F2. Nearest Beautiful Number (hard version))
ue5 小知识点 geometry script modeling
EasyClick 运行代码片段出Null
2022煤矿探放水特种作业证考试题库模拟考试平台操作
Private computing fat core concepts and stand-alone deployment
vivo大规模 Kubernetes 集群自动化运维实践
Some experience in database table structure design
Actual combat simulation │ real time error alarm of enterprise wechat robot
容斥原理(能被整除的数)
Multithreading starts from the lockless queue of UE4 (thread safe)
C file package and download