成段更新 easy

 #include <stdio.h>
#include <string.h>
#include <math.h>
#include <iostream>
#include <algorithm>
using namespace std;
const int MM=;
int num[MM<<];
void buildtree(int l,int r,int id)
{
if(l==r)
{
scanf("%d",&num[id]);return;
}
else
{
int mid=(l+r)>>;
buildtree(l,mid,id<<);
buildtree(mid+,r,id<<|);
num[id]=max(num[id<<],num[id<<|]);
}
}
int query(int L,int R,int l,int r,int id)
{
int maxx=0x80000000;
if(L<=l&&r<=R)return num[id];
else
{
int mid=(l+r)>>;
if(L<=mid)
maxx=max(query(L,R,l,mid,id<<),maxx);
if(R>mid)
maxx=max(query(L,R,mid+,r,id<<|),maxx);
return maxx;
} }
void update(int pos,int e,int l,int r,int id)
{
if(l==r)
{
num[id]=e;
}
else
{
int mid=(l+r)>>;
if(pos<=mid)
update(pos,e,l,mid,id<<);
else if(pos>mid)
update(pos,e,mid+,r,id<<|);
num[id]=max(num[id<<],num[id<<|]);
}
}
int main()
{
int t,n,cas,i,x,y;
char ch[]; while(~scanf("%d %d",&n,&t))
{
buildtree(,n,);
while(t--)
{
scanf("%s %d %d",ch,&x,&y);
if(ch[]=='U')
{
update(x,y,,n,);
}
else
{
printf("%d\n",query(x,y,,n,) );
}
} }
return ;
}

HDU 1754的更多相关文章

  1. hdu 1754 Ihate it

    I Hate It Time Limit:3000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit St ...

  2. hdu 1754 I Hate It (splay tree伸展树)

    hdu 1754 I Hate It 其实我只是来存一下我的splay模板的..请大牛们多多指教 #include<stdio.h> #include<string.h> #i ...

  3. hdu 1754 线段树(Max+单点修改)

    I Hate It Time Limit: 9000/3000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total ...

  4. hdu 1754 I Hate It (线段树功能:单点更新和区间最值)

    版权声明:本文为博主原创文章.未经博主同意不得转载.vasttian https://blog.csdn.net/u012860063/article/details/32982923 转载请注明出处 ...

  5. HDOJ(HDU).1754 I Hate It (ST 单点替换 区间最大值)

    HDOJ(HDU).1754 I Hate It (ST 单点替换 区间最大值) 点我挑战题目 题意分析 从题目中可以看出是大数据的输入,和大量询问.基本操作有: 1.Q(i,j)代表求区间max(a ...

  6. HDU 1754——I Hate It——————【线段树单点替换、区间求最大值】

    I Hate It Time Limit:3000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit St ...

  7. 线段树(单点更新) HDU 1754 I Hate It

    题目传送门 /* 线段树基本功能:区间最大值,修改某个值 */ #include <cstdio> #include <cstring> #include <algori ...

  8. hdu 1754 I Hate It 线段树 点改动

    // hdu 1754 I Hate It 线段树 点改动 // // 不多说,裸的点改动 // // 继续练 #include <algorithm> #include <bits ...

  9. hdu 1754 I Hate It (模板线段树)

    http://acm.hdu.edu.cn/showproblem.php?pid=1754 I Hate It Time Limit: 9000/3000 MS (Java/Others)    M ...

  10. hdu 1754 线段树模板题

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1754 #include <cstdio> #include <cmath> # ...

随机推荐

  1. 收缩 虚拟硬盘 shrink vhd

    在使用WIN2012 的Hyper-v的虚拟磁盘时, 有时需要将磁盘中未使用的控件收缩掉, 这时就需要使用Hyper-v磁盘工具的收缩功能. 如果使用Hyper-v磁盘工具, 不能对vhd虚拟磁盘进行 ...

  2. count(*)、count(val)和count(1)的解释

    一.关于count的一些谣言: 1.count(*)比count(val)更慢!项目组必须用count(val),不准用count(*),谁用扣谁钱! 2.count(*)用不到索引,count(va ...

  3. 【css】多行文字图片混排容器内垂直居中解决方案

    css:   .box-wrap{display:table;width:200px;height:200px;*position:relative;}/*最外边的容器,需固定宽高*/ .box-ha ...

  4. 搭建LAMP

    RPM包和源码包存放位置 /usr/local/src 源码包编译安装位置 /usr/local/apache /usr/local/mysql /usr/local/php 默认MySQL 数据库位 ...

  5. [Ogre][地形]OgreTerrain分析以及使用

    Ogre 1.7.2中的地形教程 ○读者可以对照着Ogre1.7.2中的terrain.h源码进行阅读加深理解,蓝色部分均为源码 ○去除了一些具体场景比如添加mesh,设置setAmbientLigh ...

  6. [转]iOS学习之UINavigationController详解与使用(二)页面切换和segmentedController

    转载地址:http://blog.csdn.net/totogo2010/article/details/7682433 iOS学习之UINavigationController详解与使用(一)添加U ...

  7. 【转】详细讲解Java中log4j的使用方法

    转载地址:http://www.233.com/Java/zhuangye/20070731/142625631.html 1.Log4j是什么? Log4j可以帮助调试(有时候debug是发挥不了作 ...

  8. Power Network 分类: POJ 2015-07-29 13:55 3人阅读 评论(0) 收藏

    Power Network Time Limit: 2000MS Memory Limit: 32768K Total Submissions: 24867 Accepted: 12958 Descr ...

  9. linux 帮助命令

    帮助命令 man(manual) 可以用来查看1 命令 2 配置文件 格式 man ls 1 查看命令 看第一行NAME 如果要看-l ,那么直接输入/-l 2 查看配置文件 man 查看配置文件信息 ...

  10. lua中奇葩用法

    th> a=torch.zeros(,) [.0001s] th> a [torch.DoubleTensor of size 1x5] [.0002s] th> a[] [torc ...