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 ...
随机推荐
- luogu3799 妖梦拼木棒
题目大意 有n根木棒,现在从中选4根,想要组成一个正三角形,问有几种选法?木棒长度都<=5000. 题解 根据容斥原理,三角形两条边分别由长度相等的单根木棒组成,另一条边由两条小于该边长的木棒构 ...
- [转]详细解读TrueSkill 排名系统
概要 大多数竞技游戏都有一个评价玩家是否完成目标的度量指标,它是游戏的基础.对于包含两个或两个以上玩家(多玩家比赛)的比赛,常涉及到游戏玩家技能的排名方法.游戏鼓励玩家之间相互竞争,玩家不只要赢得单场 ...
- Android.mk中添加宏定义【转】
本文转载自:http://blog.csdn.net/huangyabin001/article/details/38302021 在Boardconfig.mk 中添加一个 IS_FLAG := t ...
- 计算机网络自顶向下方法第2章-应用层(application-layer).2
2.4 DNS:因特网的目录服务 2.4.1 DNS提供的服务 DNS的定义 实体层面看,DNS是一个由分层的DNS服务器实现的分布式数据库 协议层面看,DNS是一个使得主机能够查询分布式数据库的应用 ...
- Citrix架构
本图为citrix在Azure上的基本架构 包含了netscaler, VDA, DDC, AD四台服务器以及Azure SQL服务
- HDU2080 夹角有多大2
2019-05-17 15:00:09 加油加油,fightting !!! 这道题不知道acos()函数,acos()返回的是弧度,转化成度数要 / PI * 180 也没有想到通过向量 但是想到了 ...
- WinForm中DataReader绑定到DataGridView的两种方法
在WinForm中,DataReader是不能直接绑定到DataGridView的,我想到了用两种方法来实现将DataReader绑定到DataGridView. SqlCommand command ...
- 第7章 性能和可靠性模式 Load-Balanced Cluster(负载平衡群集)
上下文 您已经决定在设计或修改基础结构层时使用群集,以便在能够适应不断变化的要求的同时保持良好的性能. 问题 在保持可接受的性能级别的同时,如何设计一个可适应负载变化的.可伸缩的基础结构层? 影响因素 ...
- img和div的宽度不一样问题和li之间空隙问题的解决方案
img和div宽度不一致问题 今天写代码,遇到一个小问题,我把一张图片放进一个div里,然后没有设置任何的padding和margin,但是发现图片和div的高度不一样,在img的下方出现了3px的空 ...
- 利用JavaScript制作计算器
<html> <head> <meta charset="utf-8"> <title>无标题文档</title> &l ...