HDU 1754 I Hate It
来源:互联网 发布:海龟交易系统源码 编辑:程序博客网 时间:2024/06/06 05:19
这题算是最基本的线段树的题目
如果刚学习线段树的还是建议自己不要看代码 独立的把代码敲出来。
不过这道题还是给我一点教训尽量别用cin cout 这个会卡一些时间
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1754
#include<map>#include<set>#include<stack>#include<cmath>#include<queue>#include<bitset>#include<math.h>#include<vector>#include<string>#include<stdio.h>#include<cstring>#include<iostream>#include<algorithm>#define lson l, mid, rt<<1#define rson mid + 1, r, rt<<1|1//#pragma comment(linker, "/STACK:102400000,102400000")using namespace std;typedef double db;typedef long long ll;typedef unsigned int uint;typedef unsigned long long ull;const db eps = 1e-5;const int N = 1e6 + 10;const int M = 1e5 + 10;const ll MOD = 1000000007;const int mod = 1000000007;const int MAX = 1000000010;const double pi = acos(-1.0);const int MAXN=200000;int T[MAXN << 2];void PushUp(int rt){ T[rt] = max(T[rt << 1] ,T[rt << 1 |1]);}void Build(int l,int r,int rt){ if (l == r) { scanf("%d",&T[rt]); return; } int mid = (r + l) >>1; Build(lson); Build(rson); PushUp(rt);}void Update(int P, int C, int l, int r, int rt){ if (l == r) { T[rt] = C; return; } int mid = (r + l)>>1; if(P<=mid) Update(P, C, lson); else Update(P, C, rson); PushUp(rt);}int query(int L, int R, int l, int r, int rt){ if (L <= l && r <= R) return T[rt]; int mid = (r + l) >>1; int ans=-1; if(L<=mid) ans=max(ans,query(L,R,lson)); if(R>mid) ans=max(ans,query(L,R,rson)); return ans;}int main(){ int n, m; while (~scanf("%d%d",&n,&m)) { char str[15]; int b,c; Build(1, n, 1); while (m--) { scanf("%s%d%d",str,&b,&c); if (str[0] == 'U') Update(b, c, 1, n, 1); if (str[0] == 'Q') printf("%d\n",query(b, c, 1, n, 1)); } } return 0;}
0 0
- hdu 1754 I Hate It
- HDU 1754 I Hate It
- hdu 1754 I Hate It
- HDU 1754 I Hate It
- hdu 1754 I Hate It
- HDU 1754 I Hate It .
- HDU 1754 i hate it
- hdu 1754 I Hate It
- hdu 1754 I Hate It
- hdu 1754 I Hate It
- HDU 1754(I Hate It )
- hdu 1754 I Hate It
- hdu 1754 I Hate It
- HDU-1754-I Hate It
- hdu 1754 I Hate It
- hdu 1754 I Hate It
- hdu 1754 I hate it
- HDU 1754 I Hate It
- 字节,半字对齐,字对齐方式
- IntelliJ IDEA中怎么查看方法说明
- lca(最近公共祖先)倍增模板【pascal】
- 【JZOJ4858】【GDOI2017模拟11.4】Walk
- 【codevs 1092】不高兴的津津
- HDU 1754 I Hate It
- 必须了解的浏览器渲染性能
- 人脸识别引擎SeetaFaceEngine简介及在windows7 vs2013下的编译
- 调整数组顺序使奇数位于偶数前面
- zabbix从2.6到3.0 脚本参数设置的变化
- Linux C——select函数详解及其应用
- 文件操作
- Twisted学习(二)--------------构造Deferreds
- 计算点云的最小BBOX