// hdu 1754 I Hate It 线段树 点改动
//
// 不多说,裸的点改动
//
// 继续练
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
#define ceil(a,b) (((a)+(b)-1)/(b))
#define endl '\n'
#define gcd __gcd
#define highBit(x) (1ULL<<(63-__builtin_clzll(x)))
#define popCount __builtin_popcountll
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
const long double PI = acos(-1.L); template<class T> inline T lcm(const T& a, const T& b) { return a/gcd(a, b)*b; }
template<class T> inline T lowBit(const T& x) { return x&-x; }
template<class T> inline T maximize(T& a, const T& b) { return a=a<b?b:a; }
template<class T> inline T minimize(T& a, const T& b) { return a=a<b?a:b; } const int maxn = 8 * 1e5 +8;
int maxv[maxn];
int n,m;
const int inf = 0x7f7f7f7f;
void build(int root,int L,int R){
if (L==R){
scanf("%d",&maxv[root]);
return ;
}
int M = L + ( R - L ) / 2;
build(root*2,L,M);
build(root*2+1,M+1,R);
maxv[root] = max(maxv[root*2],maxv[root*2+1]);
}
int p,v; void update(int root,int L,int R){
if (L==R){
maxv[root] = v;
return ;
}
int M = L + ( R - L ) / 2;
if (p<=M) update(root*2,L,M);
else update(root*2+1,M+1,R);
maxv[root] = max(maxv[root*2],maxv[root*2+1]);
} int query(int root,int ql,int qr,int L,int R){
if (ql<=L && R<=qr){
return maxv[root];
}
int M = L + ( R - L) / 2;
int ans = 0;
if (ql<=M) ans = max(ans,query(root*2,ql,qr,L,M));
if (M<qr) ans = max(ans,query(root*2+1,ql,qr,M+1,R));
return ans;
} void init(){
build(1,1,n);
char s[3];
for (int i=0;i<m;i++){
int x,y;
scanf("%s%d%d",s,&x,&y);
if (s[0]=='Q'){
printf("%d\n",query(1,x,y,1,n));
}else {
p = x;
v = y;
update(1,1,n);
}
}
} int main() {
// freopen("G:\\Code\\1.txt","r",stdin);
while(scanf("%d%d",&n,&m)!=EOF){
init();
}
return 0;
}

hdu 1754 I Hate It 线段树 点改动的更多相关文章

  1. HDU 1754 I Hate It(线段树之单点更新,区间最值)

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

  2. HDU 1754 I Hate It 线段树RMQ

    I Hate It Time Limit: 1 Sec  Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=175 ...

  3. HDU 1754 I Hate It 线段树单点更新求最大值

    题目链接 线段树入门题,线段树单点更新求最大值问题. #include <iostream> #include <cstdio> #include <cmath> ...

  4. HDU 1754 I Hate It(线段树单点替换+区间最值)

    I Hate It [题目链接]I Hate It [题目类型]线段树单点替换+区间最值 &题意: 本题目包含多组测试,请处理到文件结束. 在每个测试的第一行,有两个正整数 N 和 M ( 0 ...

  5. HDU 1754 I Hate It (线段树)

    题意:略. 析:裸的线段树. 代码如下: #pragma comment(linker, "/STACK:1024000000,1024000000") #include < ...

  6. HDU 1754 I Hate It(线段树区间查询,单点更新)

    描述 很多学校流行一种比较的习惯.老师们很喜欢询问,从某某到某某当中,分数最高的是多少. 这让很多学生很反感.不管你喜不喜欢,现在需要你做的是,就是按照老师的要求,写一个程序,模拟老师的询问.当然,老 ...

  7. HDU 1754 I Hate It (线段树)

    题目链接 Problem Description 很多学校流行一种比较的习惯.老师们很喜欢询问,从某某到某某当中,分数最高的是多少. 这让很多学生很反感. 不管你喜不喜欢,现在需要你做的是,就是按照老 ...

  8. hdu 1754 I Hate It 线段树基础题

    Problem Description 很多学校流行一种比较的习惯.老师们很喜欢询问,从某某到某某当中,分数最高的是多少. 这让很多学生很反感. 不管你喜不喜欢,现在需要你做的是,就是按照老师的要求, ...

  9. hdu 1754 I Hate It(线段树水题)

    >>点击进入原题测试<< 思路:线段树水题,可以手敲 #include<string> #include<iostream> #include<a ...

随机推荐

  1. luogu1082 同余方程

    题目大意:求$$ax\equiv 1(\ \mathrm{mod}\ m)$$的最小正整数解. 因为$ax-1|m$,故令$ax-1=-ym$,原方程就变成了$ax+my=1$.根据bezout定理此 ...

  2. 使用getopt命令解析shell脚本的命令行选项 【转】

    本文转载自:http://yejinxin.github.io/parse-shell-options-with-getopt-command 在之前的一篇文章中,介绍了如何利用shell内置的get ...

  3. 软件开发 —— 极限编程(XP:Extreme Programming)

    1. 软件开发的基本概念 软件开发的过程是:需求分析.设计.编码和测试. 2. 极限编程基本内涵 极限编程是一个轻量级的.灵巧的软件开发方法:同时它也是一个非常严谨和周密的方法. 它的基础和价值观是交 ...

  4. golang iris html/temple

    在使用golang的模板语法的过程中遇见自动转义问题(或者以我的理解下发的富文本html代码不是template.html类型,而是string类型),需要强制转型 func unescaped(x ...

  5. guice基本使用,常用的绑定方式(四)

    guice在moudle中提供了良好的绑定方法. 它提供了普通的绑定,自定义注解绑定,按名称绑定等. 下面直接看代码: package com.ming.user.test; import com.g ...

  6. Fail2ban + firewalld 防护doss攻击

    系统环境:centos7.3 用途:利用fail2ban+Firewalld来防CC攻击和SSH爆破 准备工作: 1.检查Firewalld是否启用 #如果您已经安装iptables建议先关闭 ser ...

  7. Linux目录结构(二)

    Linux文件系统结的结构是树形结构,其入口从/开始,了解Linux文件系统的结构,对于我们需要掌握的基础知识点之一. 2.文件系统的组织结构简说: 当您使用Linux的时候,如果您通过ls -la ...

  8. Java基础2一基础语法

    1.标识符 定义:在Java中给类名.方法名.包名,参数名等命名时使用的字符序列即标识符 规则: 由字母.数字.下划线和$符组成 不能以数字开头 长度无限制 严格区分大小写 不能是java中的保留关键 ...

  9. 第二课 TXT读取 - 导出 - 选择顶部/底部记录 - 描述性统计 - 分组/排序

    第2课 创建数据 - 我们从创建自己的数据集开始分析.这可以防止阅读本教程的最终用户为得到下面的结果而不得不下载许多文件.我们将把这个数据集导出到一个文本文件中,这样您就可以获得从文本文件中一些拉取数 ...

  10. 【Oracle】RAC集群中的命令

    数据库名称:racdb 节点名称:rac3.rac4 注:以下命令均在grid用户中执行 1.查看集群节点的状态: [grid@rac3 ~]$ crsctl check cluster [grid@ ...