[hdu1754]I Hate It
来源:互联网 发布:miaomiaoav永久域名 编辑:程序博客网 时间:2024/05/14 09:34
传送门
http://acm.hdu.edu.cn/showproblem.php?pid=1754
题目大意
单点修改+区间查询最大值
题解
注意有多组数据
var w:array[0..800005,1..3]of longint; i,j,k:longint; n,m:longint; ch:char; a,b:longint;function max(a,b:longint):longint;begin if a>b then exit(a) else exit(b);end;procedure build(a,l,r:longint);var mid:longint;begin w[a,1]:=l; w[a,2]:=r; if l=r then begin read(w[a,3]); exit; end; mid:=(l+r)>>1; build(a<<1,l,mid); build(a<<1+1,mid+1,r); w[a,3]:=max(w[a<<1,3],w[a<<1+1,3]);end;procedure update(a,b,c:longint);var mid:longint;begin if (w[a,1]=w[a,2])and(w[a,1]=b) then begin w[a,3]:=c; exit; end; mid:=(w[a,1]+w[a,2])>>1; if b<=mid then update(a<<1,b,c) else update(a<<1+1,b,c); w[a,3]:=max(w[a<<1,3],w[a<<1+1,3]);end;function query(a,l,r:longint):longint;var mid:longint;begin if (w[a,1]=l)and(w[a,2]=r) then exit(w[a,3]); mid:=(w[a,1]+w[a,2])>>1; if r<=mid then exit(query(a<<1,l,r)) else if l>mid then exit(query(a<<1+1,l,r)) else exit(max(query(a<<1,l,mid),query(a<<1+1,mid+1,r)));end;begin while not eof do begin readln(n,m); build(1,1,n); readln; for i:=1 to m do begin readln(ch,a,b); if ch='U' then update(1,a,b); if ch='Q' then writeln(query(1,a,b)); end; end;end.
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
- 【Unity开发】A星算法(怪物终点反复改变的解决办法)
- qt mac开发注意路径问题
- hibernate3 所有参数设置明细
- 为什么直接复制项目修改名字后输入地址报404
- HashMap源码分析(Android&Java)
- [hdu1754]I Hate It
- Loadrunner 11.0在Win8系统下,controller报错81024
- 迭代器是什么
- 5.6 顶点着色器阶段
- Android 开发中,有哪些坑需要注意?
- hibernate使用hql执行查询操作时,多出update语句
- micro SD卡在windows上显示一个盘符(不能进去)、在Ubuntu上不能识别的解决方法
- C++笔记:迭代器
- 每天一点python——删除文件