#include <algorithm>
#include <iostream>
#include<sstream>
#include<cstring>
#include<string>
#include<cstdio>
#include<cctype>
#include<vector>
#include<deque>
#include<map>
#include<set> #define M 200000
#define inf 0x3f3f3f3f
typedef long long ll; using namespace std; struct Data
{
int max;
int left, right;
}tree[M*];
int n, m;
int ans;
int x, y;
char ch; void built(int l,int r,int k) {
tree[k].left = l, tree[k].right = r;
if (l == r) {
scanf("%d", &tree[k].max);
return;
}
int mid = (l + r) / ;
built(l, mid,k*);
built(mid + , r, k * + );
tree[k].max = max(tree[k * ].max, tree[k * + ].max);
} void search(int k) {
if (tree[k].left >= x && tree[k].right <= y) {
ans = max(ans, tree[k].max);
return;
}
int mid = (tree[k].left + tree[k].right) / ;
if (x <= mid) search(k * );
if(y>mid) search(k * + );
} void change_inv(int k) {
if (tree[k].left == tree[k].right) {
tree[k].max = y;
return;
}
int mid = (tree[k].left + tree[k].right) / ;
if (x <= mid) change_inv(k * );
else change_inv(k * + );
tree[k].max = max(tree[k * ].max, tree[k * + ].max);
} int main() {
while (scanf("%d%d",&n,&m)!=EOF){
built(, n, );
while (m--){
cin >> ch;
scanf("%d%d", &x, &y);
if(ch=='Q'){
ans = ;
search();
printf("%d\n", ans);
}
else {
change_inv();
}
}
}
return ;
}

HDU - 1754 线段树的更多相关文章

  1. hdu 1754 线段树(Max+单点修改)

    I Hate It Time Limit: 9000/3000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total ...

  2. HDU(1754),线段树,单点替换,区间最值

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1754 线段树模板题,update功能是单点替换,query是访问区间最大值. #include < ...

  3. hdu 1754 线段树入门

    线段树点修改  区间最大值查询 #include <cstdio> #include <cstdlib> #include <cmath> #include < ...

  4. HDU 1754 线段树 单点跟新 HDU 1166 敌兵布阵 线段树 区间求和

    I Hate It Time Limit: 9000/3000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total ...

  5. HDU 1754 线段树入门解题报告

    ---恢复内容开始--- 题意:给定区间,每个人的成绩, Q次询问,求每次询问区间中的最大值 思路:构造线段树 代码: #include<stdio.h> #include<algo ...

  6. HDU - 1754 线段树-单点修改+询问区间最大值

    这个也是线段树的经验问题,待修改的,动态询问区间的最大值,只需要每次更新的时候,去把利用子节点的信息进行修改即可以. 注意更新的时候区间的选择,需要对区间进行二分. #include<iostr ...

  7. hdu 1754 线段树(单点替换 区间最值)

    Sample Input5 61 2 3 4 5Q 1 5 //1-5结点的最大值U 3 6 //将点3的数值换成6Q 3 4Q 4 5U 2 9Q 1 5 Sample Output5659 # i ...

  8. HDU 1754线段树基本操作,建树,更新,查询

    代码线段树入门整理中有介绍. #include<cstdio> #include<algorithm> #include<cstring> #include< ...

  9. HDU 1754线段树

    第一个自己动手写的线段树,1Y还是有点小激动哈(虽然是模版题) 1 #include<cstdio> 2 #include<cstring> 3 #include<alg ...

  10. hdu 1754 线段树模板题

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1754 #include <cstdio> #include <cmath> # ...

随机推荐

  1. c++程序—三目运算符

    #include<iostream> using namespace std; #include<string> int main() { //三目运算符 ; ; ; c = ...

  2. VUE随手记坑

    1.el-select 默认选中的问题 <el-select v-model="temp.audit" placeholder="请选择"> < ...

  3. vue坑 - vue安装vue-cli报错coffee-script@1.12.7: CoffeeScript on NPM has moved to "coffeescript" (no hyphen)或者说不支

    $ npm install -g vue-cli npm WARN deprecated coffee-script@1.12.7: CoffeeScript on NPM has moved to ...

  4. C++ 设置自动启动

    WCHAR pFileName[MAX_PATH] = {}; //得到程序自身的全路径 DWORD dwRet = GetModuleFileName(NULL, pFileName, MAX_PA ...

  5. cf 766#

    天呢,太垃圾了我.. AB懵逼了半天题意,C最后搞了个DP还不对...DP太垃圾了,, #include<bits/stdc++.h> #define INF 0x7fffffff #de ...

  6. Vulkan SDK 之 Descriptor Set Layouts and Pipeline Layouts

    当我们有了一个uniform buff之后,vulkan 还不知道这个信息,需要通过descriptor进行描述. Descriptors and Descriptor Sets A descript ...

  7. HDU-1114 完全背包+恰好装满问题

    B - Piggy-Bank Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Subm ...

  8. HZNU-ACM寒假集训Day6小结 线性DP

    线性DP 考虑一组硬币面值 1,5,11 给定W,求凑出W的最少硬币个数 我们记凑出n需要用到的最少硬币数量为f(n)   我们注意到了一个很棒的性质 : f(n)只与f(n-1) f(n-5) f( ...

  9. C/C++学习笔记_gdb调试

    1.前提条件:可执行文件包含调试信息 gcc -g 2.gdb 文件名 ---启动gdb调试 3.查看代码的命令 当前文件: list 行号(函数名) 指定文件: list 文件名:行号(函数名)4. ...

  10. PAT Advanced 1151 LCA in a Binary Tree (30) [树的遍历,LCA算法]

    题目 The lowest common ancestor (LCA) of two nodes U and V in a tree is the deepest node that has both ...