【线段树】
Tw_light
这个作者很懒,什么都没留下…
展开
-
POJ 3468【线段树,懒惰标记】
题目:http://poj.org/problem?id=3468 给出N个整数,进行M次询问,C a b c 表示给区间[a, b]中的每一个数加上c, Q a b 表示询问区间[a, b] 的和 #include<iostream> #include<algorithm> #include<cstring> #include<string> #include<cstdio> #define ll long long int using na原创 2020-05-18 09:09:30 · 215 阅读 · 0 评论 -
关于线段树
线段树(Segment Tree) 线段树可在O(log n)的时间复杂度内实现单点修改、区间修改、区间查询(区间和,区间最大/最小值)等操作 线段树的结构和建树 线段树建树 区间查询(区间求和) 单点修改 线段树把一整个线段划分成一个树形结构,将每个长度不为1的区间划分成左右两个区间递归求解。 设用数组st[ ] 来保存线段树, st[i] 为线段树上编号为i的结点的值 (st[i]表示编号为i的结点所管理的区间的和) st[1] = a[1] + a[2] + a[3] + a[4] st[2]原创 2020-05-18 09:19:34 · 262 阅读 · 0 评论 -
HDU1166敌兵布阵【线段树】
题目:http://acm.hdu.edu.cn/showproblem.php?pid=1166 #include<iostream> #include<algorithm> #include<cstring> #include<string> #include<cstdio> using namespace std; const int INF = 0x3f3f3f3f; const int MAXN = 1e5 + 7; int T, n;原创 2020-05-13 11:08:35 · 153 阅读 · 0 评论