关于st表
#include<cstdio>
#include<iostream>
#include<cmath>
#include<cctype>
#include<algorithm>
using namespace std;
int n,m;
int logg[];
int maxx[][];
inline int read(){
int ret=;
char ch=getchar();
while(ch<''||ch>'')ch=getchar();
while(ch>=''&&ch<='')ret=ret*+ch-'',ch=getchar();
return ret;
}
int main(){
n=read(),m=read();
logg[]=-;
for(int i=;i<=n;++i)maxx[i][]=read(),logg[i]=logg[i>>]+;
for(int i=;i<=;++i){
for(int j=;j+(<<i)-<=n;++j){
maxx[j][i]=max(maxx[j][i-],maxx[j+(<<i-)][i-]);
}
}
for(int i=;i<=m;++i){
int l,r;
l=read();r=read();int len=logg[r-l+];
cout<<max(maxx[l][len],maxx[r-(<<len)+][len]);putchar('\n');
}
return ;
}
代码
关于st表的更多相关文章
- POJ3693 Maximum repetition substring [后缀数组 ST表]
Maximum repetition substring Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 9458 Acc ...
- 【BZOJ-2006】超级钢琴 ST表 + 堆 (一类经典问题)
2006: [NOI2010]超级钢琴 Time Limit: 20 Sec Memory Limit: 552 MBSubmit: 2473 Solved: 1211[Submit][Statu ...
- 【BZOJ-3956】Count ST表 + 单调栈
3956: Count Time Limit: 10 Sec Memory Limit: 512 MBSubmit: 173 Solved: 99[Submit][Status][Discuss] ...
- 【BZOJ-4569】萌萌哒 ST表 + 并查集
4569: [Scoi2016]萌萌哒 Time Limit: 10 Sec Memory Limit: 256 MBSubmit: 459 Solved: 209[Submit][Status] ...
- 【BZOJ-4310】跳蚤 后缀数组 + ST表 + 二分
4310: 跳蚤 Time Limit: 20 Sec Memory Limit: 512 MBSubmit: 180 Solved: 83[Submit][Status][Discuss] De ...
- HDU5726 GCD(二分 + ST表)
题目 Source http://acm.hdu.edu.cn/showproblem.php?pid=5726 Description Give you a sequence of N(N≤100, ...
- Hdu 5289-Assignment 贪心,ST表
题目: http://acm.hdu.edu.cn/showproblem.php?pid=5289 Assignment Time Limit: 4000/2000 MS (Java/Others) ...
- Bzoj 2006: [NOI2010]超级钢琴 堆,ST表
2006: [NOI2010]超级钢琴 Time Limit: 20 Sec Memory Limit: 552 MBSubmit: 2222 Solved: 1082[Submit][Statu ...
- ST表poj3264
/* ST表多次查询区间最小值 设 g[j][i] 表示从第 i 个数到第 i + 2 ^ j - 1 个数之间的最小值 类似DP的说 ans[i][j]=min (ans[i][mid],ans ...
- COJ 1003 WZJ的数据结构(三)ST表
WZJ的数据结构(三) 难度级别:B: 运行时间限制:3000ms: 运行空间限制:51200KB: 代码长度限制:2000000B 试题描述 请你设计一个数据结构,完成以下功能: 给定一个大小为N的 ...
随机推荐
- MySQL高级管理
#mysql数据库密码的修改 一.mysql密码的修改与恢复 1.修改密码 mysqladmin -u root -p123 password 456 数据库内修改 method.first: upd ...
- LeetCode 1049. Last Stone Weight II
原题链接在这里:https://leetcode.com/problems/last-stone-weight-ii/ 题目: We have a collection of rocks, each ...
- 保护 SSH 的三把锁
转自:https://www.ibm.com/developerworks/cn/aix/library/au-sshlocks/index.html 简介 如果需要远程访问计算机并启用了 Secur ...
- DotNetty 常用库
https://github.com/Azure/DotNetty DotNetty中几个重要的库(程序集): DotNetty.Buffers: 对内存缓冲区管理的封装. DotNetty.Code ...
- Processing设计Android APP(1) - 安装
1.安装环境: A. Android Studio B. Processing 3.4 (64bit) 首先,直接安装Android Studio,我这里版本是3.2.1. 然后,新建一个Sample ...
- Servlet相关的几种乱码
1. 页面中文显示乱码 原因: response中的内容会先输入到response缓冲区,然后再输入到传给浏览器,所以要将缓冲区和浏览器的编码都设置成utf-8 1)未使用jsp,而是在servlet ...
- Java封装jar包对外提供可执行文件
编写Main方法,封装jar包 1.编写Main方法 import java.util.Date; /** * 描述 : * * @Author : zhanghao * @Time : 2019/1 ...
- Cesium学习笔记-工具篇20-PrimitiveTexture自定义渲染-贴图【转】
前几篇博客我们了解了自定义点.线.面绘制,这篇我们接着学习cesium自定义纹理贴图.我们完成点线面的绘制,只是绘制出了对象的框架,没有逼真的外观.逼真外观是需要设置材质来实现:Material . ...
- 如何在真实串口驱动还未加载的情况下调试uboot?
1. 先找出真实串口是什么型号 1.1 怎么找?笔者提供两种方案: 方案一: 若当前的板子支持dm,从uboot的dts找串口节点对应的compatible属性 方案二: 从linux内核的dts找串 ...
- leetcode 10. Regular Expression Matching 、44. Wildcard Matching
10. Regular Expression Matching https://www.cnblogs.com/grandyang/p/4461713.html class Solution { pu ...