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 ...
随机推荐
- 使用fastcgi部署django应用
1.fastcgi和cgi的区别 1)CGI (Common Gateway Interface): 用来作为 Web Server 同 Python, PHP 等的通信手段.而在静态网页的时代, 只 ...
- meta标签的作用及整理
[转载] meta的标签的使用是我在前端学习中曾经困惑过一段时间的问题.一方面不是很了解meta标签的用途,另一方面是对于meta标签里的属性和值不是懂,也不知道从哪里冒出来的,所以这篇文章专门整理下 ...
- Cupid's Arrow[HDU1756]
Cupid's Arrow Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Tot ...
- JavaScript与jquery的对比
javascript jQuery 入口函数 只能有一个,如果有多个,后面的会覆盖前面 可以有多个,并且不会发生覆盖的情况 代码容错性 代码容错性差,代码出现错误,会影响到后面代码的运行. 代码容 ...
- jquey中的事件绑定
三种方法: $(selector).live(events, data, handler); // jQuery 1.3+ $(document).delegate(se ...
- 关于CommandTimeOut
指示在终止尝试和产生错误之前执行命令期间需等待的时间. 设置和返回值 设置或返回长整型值,该值指示等待命令执行的时间(单位为秒).默认值为 30. 说明 Connection 对象或Command 上 ...
- MemCached总结二:数据管理指令
管理memcached中的数据包括添加(add).修改(set).删除(delete)及获取(get)等操作. 命令格式: 1.set set userId 0 0 5 12345 STORED ge ...
- 【Oracle】三种方式查看SQL语句的执行计划
查看执行计划的方式有三种: EXPLAIN PLAN .V$SQL_PLAN .SQL*PLUS AUTOTRACE 1.EXPLAIN PLAN: 显示执行相应语句时可以使用的理论计划 读取执行计划 ...
- 使用boost.python进行混合开发
使用boost.python进行混合开发 原文请参照官网和各方参考,本文有改动! 参考链接:http://blog.csdn.net/lanbing510/article/details/121979 ...
- 移动端的0.5px
最近写移动端页面写的比较多,边边基本上都是用的1px,视觉上也确实有点小粗,这不闲下来啦,具体的研究了下0.5px是怎么实现的,切记,这个效果只有在手机上才能看到效果的 利用了css3的缩放效果 &l ...