题意:略。

析:裸的线段树。

代码如下:

#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. Linux下的shell编程(一)BY 四喜三顺

    Ctrl + Alt + Tvim文本编辑器:i(插入模式),v(可视模式),Esc(普通模式),:w(保存),:r(打开),:q(退出)gvim 文本编辑器vim的升级版gedit 更常用的文本编辑 ...

  2. javascript URI的编码

    用encodeURIComponent,但是不清楚她和encodeURI的区别, w3school 对其的解释: encodeURIComponent() 函数可把字符串作为 URI 组件进行编码.( ...

  3. python学习笔记:文件操作和集合(转)

    转自:http://www.nnzhp.cn/article/16/ 这篇博客来说一下python对文件的操作. 对文件的操作分三步: 1.打开文件获取文件的句柄,句柄就理解为这个文件 2.通过文件句 ...

  4. Java和C++中的static

    1.Java类中的static变量和static方法会在类装载的过程中就得到内存分配,然后就会进行初始化工作.最多可能会被初始化3次,静态代码块的执行在main方法之前. static变量不可以在构造 ...

  5. MC的一些具体的应用的例子的总结

    任何东西,都有其适用的场景,在合适的场景下,才能发挥好更大的作用. 对于memcached,使用内存来存取数据,一般情况下,速度比直接从数据库和文件系统读取要快的多. memcached的最常用的场景 ...

  6. List集合转换为数组形式

    通过List集合对象的转类型函数 .ToArray() 如List<decimal> → deciaml[] 代码如下: var ComIdList = ComList.Select(p ...

  7. XidianOJ 1172 Hiking

    题目描述 BlacKin and GKCY are going hiking together. Besides their personal items, there are some items ...

  8. Python学习笔记(四)字符串型

    字符串是 Python 中最常用的数据类型.我们可以使用引号('或")来创建字符串. 在最新的Python 3版本中,字符串是以Unicode编码的,也就是说,Python的字符串支持多语言 ...

  9. codeforces 361 A - Mike and Cellphone

    原题: Description While swimming at the beach, Mike has accidentally dropped his cellphone into the wa ...

  10. pci

    https://www.ibm.com/developerworks/cn/linux/l-pci/