成段更新 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. JavaEE基础(二十七)/反射、JDK新特性

    1.反射(类的加载概述和加载时机) A:类的加载概述 当程序要使用某个类时,如果该类还未被加载到内存中,则系统会通过加载,连接,初始化三步来实现对这个类进行初始化. 加载  就是指将class文件读入 ...

  2. 文件名唯一(A.txt => An.txt)

    /// <summary> /// 文件名唯一(A.txt => An.txt) /// </summary> /// <param name="full ...

  3. C#:反射

    using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.T ...

  4. ASP.NET数据验证控件的常用的属性

    一.非空验证     RequiredFieldValidator ControlToValidate 所验证的控件ID Text 出错时的提示的文本 ErrorMessage 提交给Validati ...

  5. gets()和getchar()还有getch()的区别

    getch()和getchar()区别:1.getch(): 所在头文件:conio.h 函数用途:从控制台读取一个字符,但不显示在屏幕上例如: char ch;或int ch: getch();或c ...

  6. mini.open打开窗口时传递参数

    mini.open({ url: "xxx.html", showMaxButton: false, allowResize: false, title: '标题', width: ...

  7. Java线程池与java.util.concurrent

    Java(Android)线程池 介绍new Thread的弊端及Java四种线程池的使用,对Android同样适用.本文是基础篇,后面会分享下线程池一些高级功能. 1.new Thread的弊端执行 ...

  8. java Web应用配置log4j日志记录

    公司启动全国支票影像系统,有这样一个功能是和消息中间件打交道,需要记录每一个报文出错情况,因为方便后期开发人员的调试,我选用了log4j作为日志记录,好了废话不多说了! 第一步:首先建立一个WEB工程 ...

  9. Wpf再次学习,分享给入门的朋友

    一.WPF介绍 先说下WPF,她的简称是Windows Presentation Foundation,注意到Presentation这个单词了吧,展现的意思,后面那个是基础,展现基础,WPF是一种展 ...

  10. 5-JS函数

    函数 定义函数 JS中有3种定义函数的方法: 函数声明 用函数声明定义函数的方式如下: function abs(x) { if (x >= 0) { return x; } else { re ...