
线段树
今天没吃药
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
POJ3264 - Balanced Lineup (线段树 基本操作)
题目链接 : POJ3264 - Balanced Lineup 思路 代码 思路这道题是一个线段树的基本应用,将树节点设置为如下:struct Node { int l, r; // 区间的起点和终点 int ls, rs; // 左右孩子,所处的位置 int maxn, minn; // 区间最大最小值 }代码#include <algorithm> #include <原创 2015-08-30 01:29:25 · 442 阅读 · 0 评论 -
HDU1166 - 敌兵布阵 (线段树 基本操作)
题目链接 : HDU1166 - 敌兵布阵思路 代码 思路线段树的基本应用,单点更新和区间查询代码#include <algorithm> #include <iostream> #include <cstdio>// 为了方便下面使用 #define lson tree[root].ls #define rson tree[root].rsusing namespace std; typedef原创 2015-08-30 01:48:28 · 475 阅读 · 0 评论 -
POJ3468 - A Simple Problem with Integers (线段树 区间更新)
POJ3468 - 解题报告 (线段树 区间更新)poj3468 - A Simple Problem with IntegersPOJ3468 - 解题报告 线段树 区间更新 思路 面对的问题 解决的方法 具体的操作 代码 思路 线段树的应用,区间更新 和 区间查询,比较困难的就是区间更新了。 面对的问题线段树之所以能够快速进行区间操作,是因为它的每一个区间分解得到的终止区间都是 O(logn原创 2015-08-30 01:27:31 · 781 阅读 · 0 评论 -
HDU5443 - The Water Problem (线段树)
题目链接思路线段树的应用,可是因为数据量太小,可以直接暴力代码#include <iostream> #include <cstdio> #define lson tree[root].ls #define rson tree[root].rs using namespace std; const int maxn = 1000; struct node { int ans; int原创 2015-10-07 23:49:59 · 584 阅读 · 0 评论 -
HDU1556 - Color the ball (线段树超时 利用数组解决)
题目链接思路看上去就是一道简单的线段树的应用,区间更新,单点查询,但直接做却超时了。 找优化方法的时候得到了另一种方法,利用数组来进行解决。 我们都知道如果只解决区间求和问题的时候,可以直接对数组进行处理, 处理for(int i=1; i<=n; i++) ans[i] += ans[i-1];查询result = ans[right] - ans[left-1];同样的,如果我们要对区间原创 2015-10-07 23:53:53 · 537 阅读 · 0 评论 -
HDU1754 - I Hate It (基础线段树)
题目链接思路线段树的基本应用,区间查询,单点更新代码#include <algorithm> #include <iostream> #include <cstdlib> #include <cstdio> #define lson tree[root].ls #define rson tree[root].rsusing namespace std; const int maxn = 200000原创 2015-10-07 23:48:09 · 339 阅读 · 0 评论 -
HDU1698 - Just a Hook (线段树 区间更新)
HDU1698 - Just a Hook (线段树 区间更新)题目链接思路线段树的应用,区间更新(不用更新到底,更新到终止节点就行,查询时再将所涉及的节点信息push_down下来),颜色的数量用一个数组记录下来就行代码#include <iostream> #include <cstdlib> #include <cstring> #include <cstdio> #define lson t原创 2015-10-07 23:52:15 · 454 阅读 · 0 评论