// 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;
}

最新文章

  1. pyMysql
  2. 利用JAVA想数据库中提交数据
  3. Struts2(十四)拦截器实现权限管理
  4. 【BZOJ】1927: [Sdoi2010]星际竞速(费用流)
  5. 理解C#系列 / .NET体系结构
  6. javascript插件编写小结
  7. WPF 自己动手来做安装卸载程序
  8. JQuery -&amp;gt; 超级简单的下拉菜单
  9. 用Python实现gmail邮箱服务,实现两个邮箱之间的绑定(上)
  10. thinkinginjava学习笔记01_导论
  11. Servlet--超链接,表单提交,重定向,转发4种情况的路径
  12. [转] 如何轻松愉快地理解条件随机场(CRF)?
  13. mysqlfrm初步使用
  14. matplotlib 画动态图以及plt.ion()和plt.ioff()的使用
  15. Ubuntu 14.04(64位)+GTX970+CUDA8.0+Tensorflow配置 (双显卡NVIDIA+Intel集成显卡) ------本内容是长时间的积累,有时间再详细整理
  16. 2019.01.20 NOIP模拟 迅雷(kruskal/二分+并查集)
  17. .NetCore利用BlockingCollection实现简易消息队列
  18. LeetCode263——Ugly Number
  19. maven配置国内镜像库
  20. Jmeter分布式

热门文章

  1. WPF中ListBox ListView数据翻页浏览笔记(强调:是数据翻页,非翻页动画)
  2. hihoCoder-1830 2018亚洲区预选赛北京赛站网络赛 C.Cheat 模拟
  3. HTML5动态时钟
  4. lua类实现
  5. Git Learning Part III - working remotely (Github)
  6. IE不支持 ES6 Promise 对象的解决方案
  7. 读《Android电视机(机顶盒)初次开发的一些经验分享》后的笔记
  8. 杭电2602 Bone Collector 【01背包】
  9. java操作Excel的poi基础语法
  10. day28 re(正则)模块