hdu 1754 I Hate It 线段树 点改动
// 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 线段树 点改动的更多相关文章
- HDU 1754 I Hate It(线段树之单点更新,区间最值)
I Hate It Time Limit: 9000/3000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total ...
- 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 ...
- HDU 1754 I Hate It 线段树单点更新求最大值
题目链接 线段树入门题,线段树单点更新求最大值问题. #include <iostream> #include <cstdio> #include <cmath> ...
- HDU 1754 I Hate It(线段树单点替换+区间最值)
I Hate It [题目链接]I Hate It [题目类型]线段树单点替换+区间最值 &题意: 本题目包含多组测试,请处理到文件结束. 在每个测试的第一行,有两个正整数 N 和 M ( 0 ...
- HDU 1754 I Hate It (线段树)
题意:略. 析:裸的线段树. 代码如下: #pragma comment(linker, "/STACK:1024000000,1024000000") #include < ...
- HDU 1754 I Hate It(线段树区间查询,单点更新)
描述 很多学校流行一种比较的习惯.老师们很喜欢询问,从某某到某某当中,分数最高的是多少. 这让很多学生很反感.不管你喜不喜欢,现在需要你做的是,就是按照老师的要求,写一个程序,模拟老师的询问.当然,老 ...
- HDU 1754 I Hate It (线段树)
题目链接 Problem Description 很多学校流行一种比较的习惯.老师们很喜欢询问,从某某到某某当中,分数最高的是多少. 这让很多学生很反感. 不管你喜不喜欢,现在需要你做的是,就是按照老 ...
- hdu 1754 I Hate It 线段树基础题
Problem Description 很多学校流行一种比较的习惯.老师们很喜欢询问,从某某到某某当中,分数最高的是多少. 这让很多学生很反感. 不管你喜不喜欢,现在需要你做的是,就是按照老师的要求, ...
- hdu 1754 I Hate It(线段树水题)
>>点击进入原题测试<< 思路:线段树水题,可以手敲 #include<string> #include<iostream> #include<a ...
随机推荐
- luogu1965 转圈游戏
题目大意 n 个小伙伴(编号从 0 到 n-1)围坐一圈玩游戏.按照顺时针方向给 n 个位置编号,从0 到 n-1.最初,第 0 号小伙伴在第 0 号位置,第 1 号小伙伴在第 1 号位置,--,依此 ...
- Softmax回归——logistic回归模型在多分类问题上的推广
Softmax回归 Contents [hide] 1 简介 2 代价函数 3 Softmax回归模型参数化的特点 4 权重衰减 5 Softmax回归与Logistic 回归的关系 6 Softma ...
- 数组map方法与如何使用ES5实现
数组map方法与如何使用ES5实现 JavaScript Array map() 方法 定义 map() 方法返回一个新数组,数组中的元素为原始数组元素调用函数处理后的值. map() 方法按照原始数 ...
- IT业常见职位英语缩写全攻略及详解
现在中国人流行起英文名字,连职位也跟着作秀,什么CEO.COO.CFO.CTO.CIO啦,那CEO.COO.CFO.CTO.CIO到底是什么意思呢?总被这些概念搞晕,这可不是搞IT的应该犯的错误哦,好 ...
- MVC中使用UpdateModel获取接口参数
废话少说,直接上代码: 模型类定义: public class RequestModel { public string Name { get; set; } public float Age { g ...
- SDAutoLayout的使用
## 简介- IOS布局的三个阶段:MagicNumber -> AutoResizingMask -> AutoLayout- 自动布局三大框架:UILayoutConstraint(原 ...
- 通过Hibernate实现添加功能
package com.demo.dao; import org.hibernate.Session; import org.hibernate.SessionFactory; import org. ...
- 如何用PYTHON代码写出音乐
什么是MIDI 博主本人虽然五音不全,而且唱歌还很难听,但是还是非常喜欢听歌的.我一直在做这样的尝试,就是通过人工智能算法实现机器自动的作词和编曲(在这里预告下,通过深度学习写歌词已经实现了,之后会分 ...
- Vtk读取并显示保存图像
(1):Vtk读取并显示图像:三种方法 转载:未知出处 转载:用VTK显示平面图片:http://blog.csdn.net/tonylk/article/details/464881 用到vtkJP ...
- ZBrush中的PolyPainting如何理解?
什么是PolyPainting? PolyPainting在ZBrush ®中是一种创建纹理的方法,该方法通过对每个多边形顶点应用单一RGB值来着色模型.此方法无需使用UV坐标.通过直接对顶点应用颜色 ...