线段树
这是一道线段树的裸题……带单点修改的RMQ
为什么我会想到写这么一道傻逼题呢?是因为这样……aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAABQYAAABVCAIAAACU464EAAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAgAElEQVR4nO3df1BTd94v8M8JaMvSfbogtDSAtGCiWBa9PmHxdkZnOoBFaG/3amuH9jLWgQ6ls7sVWIedwdarrXOXhyW2u3cXeRZHHUZ56q4818cSqYXrvTjTkZKHlSwVTSS9CGSx8kB/bESr5Nw/vsnJSXJOCJCQg7xf4zjkm+855xv4wHw/5/vjcDzPE8yG13eM4zjfQlbC8zzHcSqVyqt8enr6/v377N2IiIiIiAjhJOxd3oWVC1QqVWRkJMdxXuWsssPh4HlepVKpVCrfCl4lsNghDkEJEIegBIhDUALEISgB4nBuOPY9ujoe3mbMy5o4okX+EbSxDpVKtag/AgAAAACApAeguw4PHhaWRKTyWw0WCLt9Eu5WAAAAAAAALC1IiRWBzSUIdysAAAAAAACWFqTEioBRYgAAAAAAgIWHlFgR2KLzcLcCAAAAAABgaUFKrAgYJQYAAAAAAFh4SIkBAAAAAABgiYoMdwOAiIjjuEBGiXMqujsPZQd4zpyKbq+SwI8FAAAAAABYCpASK8I8Z017Zb9C6ivOgX0zZAAAAAAAUBCr/uXsqv7X2gY+KFigK3aUpteubf+0MiWUF+nazZWd0FV397yeGsrLzNWST4m9gqCjNL3oiGcN5w+vazdXdsK33HIsT1t7WSgsabzVtDnkjZYgZL+Bpb7jdRWD7RRz8JB2Y0CnZ/XdtFszGrZEz7qVAAAAAABhJtuBl+nwiwpkkwX5pEA4xCPRNeyN37fKO0W0HCurogPmgXINkf1UXX+jTXhL6Ld7lm9I6yyOc70Q9dhF5Zeau2t6xVeJKqvO3JHgfNH18ZGMbeYU2cPlLje78s0f8O2rs/LL9M+GOPeemyWcEgvRub7eXZjbNHCrybNOn/ulxA0by3Wqb7/l/NF27ebK8kJ+lyUITBP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pbr+dWS4mzR3D8BMjAfgIwAAAAAASEJfFxRImDgdyfO8w+EIa2MAAAAAAOCB5Uo38JgbUJB79+6xraYjMWsaAAAAAABCZ3p6mud5ouXhbgiAG7tTg5QYAAAAAABCa3p6OtxNAPDGEmGe5/8/RoDAu+JgVrUAAAAASUVORK5CYII=" alt="" />
我很好奇那个突然冒出来的黄色箭头是什么……所以就去切了一下这道水题……
毫无压力地快速敲完……突然萌生了一种想法:试试自底向上线段树!
重新看了下zkw大牛的《统计的力量》,发现确实好写,而且灰常好用!
写的时候出现的问题:读入应该是读到[n+1,n+n]这一段,而我读到了[n+i-1,n+n-1]……(也就是说:1~n格是树中节点,后n个格是叶子节点)
int t[N<<],a[N];
#define L (o<<1)
#define R (o<<1|1)
#define mid (l+r>>1)
void maintain(int o,int l,int r){
if (l<r) t[o]=max(t[L],t[R]);
}
void build(int o,int l,int r){
if (l==r) t[o]=a[l];
else{
build(L,l,mid);
build(R,mid+,r);
maintain(o,l,r);
}
}
void update(int o,int l,int r,int pos,int v){
if (l==r) t[o]=v;
else{
if (pos<=mid) update(L,l,mid,pos,v);
else update(R,mid+,r,pos,v);
maintain(o,l,r);
}
}
int ql,qr,ans;
void query(int o,int l,int r){
if (ql<=l && qr>=r) ans=max(ans,t[o]);
else{
if (ql<=mid) query(L,l,mid);
if (qr>mid) query(R,mid+,r);
}
}
普通线段树
int t[N<<],n,m;
void update(int p,int v){
for(t[p+=n]=v,p>>=;p;p>>=)
t[p]=max(t[p+p],t[p+p^]);
}
int ans;
void query(int l,int r){
for(l=l+n-,r=r+n+;l^r^;l>>=,r>>=){
if (!(l&)) ans=max(t[l^],ans);
if ( r&) ans=max(t[r^],ans);
}
}
zkw线段树
完整代码:(确实快了好多!而且代码短了好多……)
//HDOJ 1754
#include<cmath>
#include<vector>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#define rep(i,n) for(int i=0;i<n;++i)
#define F(i,j,n) for(int i=j;i<=n;++i)
#define D(i,j,n) for(int i=j;i>=n;--i)
#define pb push_back
#define CC(a,b) memset(a,b,sizeof(a))
using namespace std;
int getint(){
int v=,sign=; char ch=getchar();
while(!isdigit(ch)) {if(ch=='-') sign=-; ch=getchar();}
while(isdigit(ch)) {v=v*+ch-''; ch=getchar();}
return v*sign;
}
const int N=,INF=~0u>>;
const double eps=1e-;
/*******************template********************/ int t[N<<],a[N],cnt;
#define L (o<<1)
#define R (o<<1|1)
#define mid (l+r>>1)
void maintain(int o,int l,int r){
if (l<r) t[o]=max(t[L],t[R]);
} void build(int o,int l,int r){
if (l==r) t[o]=a[l];
else{
build(L,l,mid);
build(R,mid+,r);
maintain(o,l,r);
}
}
void update(int o,int l,int r,int pos,int v){
if (l==r) t[o]=v;
else{
if (pos<=mid) update(L,l,mid,pos,v);
else update(R,mid+,r,pos,v);
maintain(o,l,r);
}
}
int ql,qr,ans;
void query(int o,int l,int r){
if (ql<=l && qr>=r) ans=max(ans,t[o]);
else{
if (ql<=mid) query(L,l,mid);
if (qr>mid) query(R,mid+,r);
}
}
int main(){
#ifndef ONLINE_JUDGE
freopen("input.txt","r",stdin);
// freopen("output.txt","w",stdout);
#endif
int n,m;
while(scanf("%d%d",&n,&m)!=EOF){
F(i,,n) a[i]=getint();
build(,,n);
char s[];
F(i,,m){
scanf("%s",s); ql=getint(); qr=getint();
if (s[]=='Q') {ans=; query(,,n); printf("%d\n",ans);}
if (s[]=='U') update(,,n,ql,qr);
}
}
return ;
}
普通线段树(436MS 3996K)
//HDOJ 1754
#include<cmath>
#include<vector>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#define rep(i,n) for(int i=0;i<n;++i)
#define F(i,j,n) for(int i=j;i<=n;++i)
#define D(i,j,n) for(int i=j;i>=n;--i)
#define pb push_back
#define CC(a,b) memset(a,b,sizeof(a))
using namespace std;
int getint(){
int v=,sign=; char ch=getchar();
while(!isdigit(ch)) {if(ch=='-') sign=-; ch=getchar();}
while(isdigit(ch)) {v=v*+ch-''; ch=getchar();}
return v*sign;
}
const int N=,INF=~0u>>;
const double eps=1e-;
/*******************template********************/ int t[N<<],n,m;
void update(int p,int v){
for(t[p+=n]=v,p>>=;p;p>>=)
t[p]=max(t[p+p],t[p+p^]);
}
int ans;
void query(int l,int r){
for(l=l+n-,r=r+n+;l^r^;l>>=,r>>=){
if (!(l&)) ans=max(t[l^],ans);
if ( r&) ans=max(t[r^],ans);
}
}
int main(){
#ifndef ONLINE_JUDGE
freopen("input.txt","r",stdin);
// freopen("output.txt","w",stdout);
#endif
while(scanf("%d%d",&n,&m)!=EOF){
CC(t,);
F(i,,n) t[i+n]=getint();
D(i,n-,) t[i]=max(t[*i],t[*i+]);//这句就是build建树……
char s[];
int x,y;
F(i,,m){
scanf("%s",s); x=getint(); y=getint();
if (s[]=='Q') {ans=; query(x,y); printf("%d\n",ans);}
if (s[]=='U') update(x,y);
}
}
return ;
}
zkw线段树(218MS 4296K)
【HDOJ】【1754】I Hate It的更多相关文章
-
【HDOJ图论题集】【转】
=============================以下是最小生成树+并查集====================================== [HDU] How Many Table ...
-
【集训笔记】博弈论相关知识【HDOJ 1850【HDOJ2147
以下资料来自:http://blog.csdn.net/Dinosoft/article/details/6795700 http://qianmacao.blog.163.com/blog/stat ...
-
【HDOJ 5379】 Mahjong tree
[HDOJ 5379] Mahjong tree 往一颗树上标号 要求同一父亲节点的节点们标号连续 同一子树的节点们标号连续 问一共同拥有几种标法 画了一画 发现标号有二叉树的感觉 初始标号1~n 根 ...
-
HDOJ 1238 Substrings 【最长公共子串】
HDOJ 1238 Substrings [最长公共子串] Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Ja ...
-
HDOJ 1423 Greatest Common Increasing Subsequence 【DP】【最长公共上升子序列】
HDOJ 1423 Greatest Common Increasing Subsequence [DP][最长公共上升子序列] Time Limit: 2000/1000 MS (Java/Othe ...
-
HDOJ 1501 Zipper 【DP】【DFS+剪枝】
HDOJ 1501 Zipper [DP][DFS+剪枝] Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Ja ...
-
【HDOJ 2089】不要62
[HDOJ 2089]不要62 第一个数位dp的题 做的老困难了...只是好歹是做出来了 迈出了第一步.. 对大牛来说这样的题都是小case ps:新上一个记忆化方法 一些绕弯的题里用dfs好想些 代 ...
-
【HDOJ 5371】 Hotaru&;#39;s problem
[HDOJ 5371] Hotaru's problem Manacher算法+穷举/set Manacher算法一好文:http://blog.csdn.net/yzl_rex/article/de ...
-
【HDOJ 5654】 xiaoxin and his watermelon candy(离线+树状数组)
pid=5654">[HDOJ 5654] xiaoxin and his watermelon candy(离线+树状数组) xiaoxin and his watermelon c ...
-
【HDOJ 5399】Too Simple
pid=5399">[HDOJ 5399]Too Simple 函数映射问题 给出m函数 里面有0~m个函数未知(-1) 问要求最后1~n分别相应仍映射1~n 有几种函数写法(已给定的 ...
随机推荐
-
spring框架搭建url
MyEclipse+Tomcat+MAVEN+SVN项目完整环境搭建 http://blog.csdn.net/zhshulin/article/details/30779873 MyEclipse下 ...
-
[QoS]cisco3560限速配置案例-收集于网工泡泡
网络中常用到这些:CISCO和H3C-MAC过滤+端口限速+端口镜像+端口隔离 不同的方式不同的思想:嘎嘎 其他各个厂商的限速链接:http://pan.baidu.com/s/1hrIMoSG 密码 ...
-
疯狂VirtualBOX 实战讲学录:小耗子之VirtualBOX修炼全程重现
疯狂VirtualBOX 实战讲学录:小耗子之VirtualBOX修炼全程重现 神级虚拟技术&云计算专家”小耗子”老师震撼分享 全球第—部完整深入的中文VirtualBox技术全程实战手册 全 ...
-
jsp:useBean的使用
->Bean的基本要素: 1.必须要有一个不带参数的构造器,在jsp元素创建Bean时会调用空构造器 2.Bean类应该没有任何公共实例变量,也就是说,不允许直接访问实例变量,通过setter/ ...
-
linux-centerOs6.8安装nginx与配置
一:安装nginx 1.安装gcc(命令:yum install gcc)备注:可以输入gcc -v查询版本信息,查看是否自带安装 2.安装pcre(命令:yum install pcre-devel ...
-
通用化NPOI导出xls
前言:在导出到xls时有一些通用的元素,比如标题,列标题,内容区域,求和行,但每个xls多少有点不同,为了处理这个问题,可以使用delegate实现,这样可以把差异部分单独处理. //为了处理计算和之 ...
-
InternalError (see above for traceback): Blas GEMV launch failed: m=1, n=100
python tensorflow 运行提示错误:InternalError (see above for traceback): Blas GEMV launch failed: m=1, n=1 ...
-
第八章Jdk代理 cglib代理
什么是代理模式 代理(Proxy)是一种设计模式,提供了对目标对象另外的访问方式;即通过代理对象访问目标对象.这样做的好处是:可以在目标对象实现的基础上,增强额外的功能操作,即扩展目标对象的功能. 这 ...
-
winform 可拖动无边框窗体解决办法
方法一:通过重载消息处理实现. 鼠标的拖动只对窗体本身有效,不能在窗体上的控件区域点击拖动 /// <summary> /// 通过重载消息处理实现.重写窗口过程(WndProc),处理一 ...
-
如何更改tomcat7及以上版本内存设置
http://jingyan.baidu.com/article/295430f1c22a940c7e0050fb.html?qq-pf-to=pcqq.c2c 当在tomcat的webapps文件夹 ...