hdu1754-I Hate It(线段树)
来源:互联网 发布:中国少儿编程 logo 编辑:程序博客网 时间:2024/06/06 00:29
#include<iostream>#include<cstring>#include<cstdio>#include<cmath>#include<algorithm>#include<cstdlib>#include<map>#include<queue>#include <deque>#include <list>#include <ctime>#include <stack>#include <vector>#include<set>const int Maxn =200003;#define MODtypedef long long ll;#define FOR(i,j,n) for(int i=j;i<=n;i++)#define DFR(i,j,k) for(int i=j;i>=k;--i)#define lowbit(a) a&-a#define lson l,m,rt<<1#define rson m+1,r,rt<<1|1const int inf = 0x3f3f3f3f;const double pi = acos(-1.0);int MAX[Maxn<<2];using namespace std;int max(int a,int b){return a>b?a:b;}void PushUP(int rt){ MAX[rt]=Max(MAX[rt<<1],MAX[rt<<1|1]);}void build(int l,int r,int rt){ if(l==r){scanf("%d",&MAX[rt]);return;} int m=(l+r)>>1; build(lson); build(rson); PushUP(rt);}void update(int p,int sc,int l,int r,int rt){ if(l==r){MAX[rt]=sc;return;} int m=(l+r)>>1; if(p<=m)update(p,sc,lson); else update(p,sc,rson); PushUP(rt);}int query(int L,int R,int l,int r,int rt){ if(L<=l&&r<=R)return MAX[rt]; int m=(l+r)>>1; int ret=0; if(L<=m)ret=Max(ret,query(L,R,lson)); if(R>m)ret=Max(ret,query(L,R,rson)); return ret;}int main(){ int n,m; while(~scanf("%d%d",&n,&m)) { build(1,n,1); while(m--) {char op[2]; int a,b; scanf("%s%d%d",op,&a,&b); if(op[0]=='Q')printf("%d\n",query(a,b,1,n,1)); else update(a,b,1,n,1); } } return 0;}
0 0
- 线段树(hdu1754 I hate it)
- hdu1754-I Hate It(线段树)
- hdu1754 I hate it (线段树)
- HDU1754:I Hate It(线段树)
- hdu1754 I Hate It (线段树)
- 【HDU1754】I Hate It(线段树)
- 【HDU1754-I hate it】(线段树)
- HDU1754 I Hate It,线段树
- 线段树hdu1754 I Hate It
- 【线段树】 hdu1754 I Hate It
- hdu1754 I Hate It (线段树)
- hdu1754 I Hate It+线段树
- hdu1754 I Hate It (线段树)
- hdu1754 I Hate It (线段树)
- HDU1754 I Hate It(线段树)
- hdu1754 I Hate It(线段树)
- hdu1754 I Hate It,线段树
- hdu1754 I Hate It(线段树)
- Windows Server 2008 如何部署Domain Controller
- Effective OC: 6. 7. 8
- PHP 单引号与双引号的区别
- IMX6Solo启动流程-从Uboot到kernel 中
- spring mvc
- hdu1754-I Hate It(线段树)
- 不使用临时变量交换两个数的值
- 买点已现!阅兵前线指挥车同款电视降价大促
- LeetCode题解:Merge Sorted Array
- 根据刚体上若干个点的加速度确定任意点的加速度的方法
- 3Sum Closest
- 虚拟隔离网络外网访问(SNAT)
- maven项目中jetty运行配置
- Effective C++——条款9(第2章)