成段更新 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. NSDictionary to jsonString || 对象转json格式

    -(NSString*)DataTOjsonString:(id)object { NSString *jsonString = nil; NSError *error; NSData *jsonDa ...

  2. java面试每日一题9

    题目:判断一个数是否是2的方次幂 public class Power { public static void main(String [] args) throws NumberFormatExc ...

  3. java 面试每日一题6

    题目:古典问题:有一对兔子,从出生后第3个月起每个月都生一对兔子,小兔子长到第三个月后每个月又生一对兔子,假如兔子都不死,问每个月的兔子总数为多少? 1.程序分析: 兔子的规律为数列1,1,2,3,5 ...

  4. 【转】学习总结--Cookie & Session总结

    转载地址:http://www.phperzone.cn/portal.php?aid=718&mod=view 一.状态管理 1)什么是状态管理?   将浏览器与web服务器之间多次交互过程 ...

  5. 网络编程中获取域名和id的方法

    package com.lanqiao.java.test; import java.net.InetAddress;import java.net.UnknownHostException; pub ...

  6. logo上线

  7. Unity-Animator深入系列---控制IK

    回到 Animator深入系列总目录 要让代码控制IK,需要先在Animator中打开IK pass 然后,和IK相关的代码需要放到相应的函数中去: void OnAnimatorIK() { Deb ...

  8. noi 7627 鸡蛋的硬度

    题目链接:http://noi.openjudge.cn/ch0206/7627/ 题目讲的二分其实是一个误导, d(i,j),表示当前最优策略时,最坏的情况下: 有 J 个鸡蛋,I 个可以怀疑的楼层 ...

  9. Poj(1220),hash

    题目链接:http://poj.org/problem?id=1200 这个题,我真是无限MLE,RE,WA,太伤心了,还是写一下吧.题意很简单(英语很好读),最后看了一下金海峰的思路.果然,应该是我 ...

  10. sys模块的初步认识

    #!/usr/bin/python # Filename: cat.py import sys def readfile(filename): '''Print a file to the stand ...