题意:略。

析:裸的线段树。

代码如下:

#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <cstring>
#include <set>
#include <queue>
#include <algorithm>
#include <vector>
#include <map>
#include <cctype>
#include <cmath>
#include <stack>
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define freopenr freopen("in.txt", "r", stdin)
#define freopenw freopen("out.txt", "w", stdout)
using namespace std; typedef long long LL;
typedef pair<int, int> P;
const int INF = 0x3f3f3f3f;
const double inf = 0x3f3f3f3f3f3f;
const double PI = acos(-1.0);
const double eps = 1e-8;
const int maxn = 200000 + 5;
const int mod = 1e9 + 7;
const int dr[] = {0, 1, 0, -1, -1, 1, 1, -1};
const int dc[] = {1, 0, -1, 0, 1, 1, -1, -1};
const char *de[] = {"0000", "0001", "0010", "0011", "0100", "0101", "0110", "0111", "1000", "1001", "1010", "1011", "1100", "1101", "1110", "1111"};
int n, m;
const int mon[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
const int monn[] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
inline int Min(int a, int b){ return a < b ? a : b; }
inline int Max(int a, int b){ return a > b ? a : b; }
inline LL Min(LL a, LL b){ return a < b ? a : b; }
inline LL Max(LL a, LL b){ return a > b ? a : b; }
inline bool is_in(int r, int c){
return r >= 0 && r < n && c >= 0 && c < m;
}
int maxv[maxn<<2]; void pushup(int rt){ maxv[rt] = Max(maxv[rt<<1], maxv[rt<<1|1]); } void build(int l, int r, int rt){
if(l == r){
scanf("%d", &maxv[rt]);
return ;
}
int m = (l + r) >> 1;
build(lson);
build(rson);
pushup(rt);
} void update(int x, int val, int l, int r, int rt){
if(l == r){
maxv[rt] = val;
return ;
}
int m = (l + r) >> 1;
if(x <= m) update(x, val, lson);
if(x > m) update(x, val, rson);
pushup(rt);
} int query(int L, int R, int l, int r, int rt){
if(L <= l && r <= R) return maxv[rt];
int m = (l + r) >> 1;
int ans = -INF;
if(L <= m) ans = Max(ans, query(L, R, lson));
if(R > m) ans = Max(ans, query(L, R, rson));
return ans;
} int main(){
while(scanf("%d %d", &n, &m) == 2){
build(1, n, 1);
char s[5];
int x, y;
while(m--){
scanf("%s", s);
if(s[0] == 'Q'){
scanf("%d %d", &x, &y);
printf("%d\n", query(x, y, 1, n, 1));
}
else{
scanf("%d %d", &x, &y);
update(x, y, 1, n, 1);
}
}
}
return 0;
}

HDU 1754 I Hate It (线段树)的更多相关文章

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

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

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

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

  3. 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 ...

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

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

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

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

  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. 方法的重载(overload)和重写(override)的区别

    方法的重写Overriding和重载Overloading是Java多态性的不同表现.重写Overriding是父类与子类之间多态性的一种表现,重载Overloading是一个类中多态性的一种表现.如 ...

  2. 创建线程方式-NSOperation

    *:first-child { margin-top: 0 !important; } body > *:last-child { margin-bottom: 0 !important; } ...

  3. python 中 五种字典(dict)的遍历方法,实验法比较性能。

    1 .背景: 想知道5种遍历方法,并且知道从性能角度考虑,使用哪种. 2.结论: 使用这种方式: for key,val in AutoDict.iteritems(): temp = "% ...

  4. 关于listview的一些属性

    由于这两天在做listView的东西,所以整理出来一些我个人认为比较特别的属性,通过设置这样的属性可以做出更加美观的列表 首先是stackFromBottom属性,这只该属性之后你做好的列表就会显示你 ...

  5. Battery Historian for windows环境搭建

    Battery Historian for windows环境搭建 简介:Battery historian是一款通过上传bugreport文件分析用户手机中App的电池耗电情况的工具. Batter ...

  6. hive 全局排序

    不分发数据,使用单个reducer ; select * from dw.dw_app where dt>='2016-09-01' and dt <='2016-09-18' order ...

  7. android menu的问题

    1.简单使用 @Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.me ...

  8. java 枚举类 enum 总结

    枚举定义: enum是计算机编程语言中的一种数据类型.枚举类型:在实际问题中,有些变量的取值被限定在一个有限的范围内.例如,一个星期内只有七天,一年只有十二个月,一个班每周有六门课程等等.如果把这些量 ...

  9. 通过Percona XtraBackup添加一个slave

    假设我的master是172.16.15.8,要添加的slave是172.16.15.9 1:在主服务器执行备份操作(172.16.15.8) /usr/bin/innobackupex --comp ...

  10. CodeForces 689C Mike and Chocolate Thieves (二分)

    原题: Description Bad news came to Mike's village, some thieves stole a bunch of chocolates from the l ...