数据结构--线段树
exmy
Less is more, and more is less.
展开
-
hdoj--2795 Billboard(线段树)
2795 Billboard题解叶子结点[x, x]表示第x行还可以放置的长度;非叶子结点表示的区间[a, b]维护的是该区间中剩下长度最大的一行的长度。#include <iostream>#include <cstdio>#include <cstring>#include <algorithm>#include <cmath>using namespace std;#defin原创 2016-09-16 10:08:37 · 342 阅读 · 0 评论 -
hdoj--1754 I Hate It(线段树)
1754 I Hate It题解线段树,节点维护的是该节点管辖区间的最大值。#include <iostream>#include <cstdio>#include <cstring>#include <algorithm>#include <cmath>using namespace std;#define FIN freopen("data.in", "r", std原创 2016-09-15 23:50:00 · 266 阅读 · 0 评论 -
hdoj--1166 敌兵布阵(树状数组or线段树)
1166 敌兵布阵题解线段树:#include <iostream>#include <cstdio>#include <cstring>#include <algorithm>using namespace std;#define Avg(x, y) ((x & y) + ((x ^ y) >> 1))const int maxn = 50000 + 5;int tree[3 * max原创 2016-09-15 22:45:38 · 313 阅读 · 0 评论 -
poj--3468 A Simple Problem with Integers(线段树)
poj 3468题意有 NN 个数,A1,A2,...,AnA_1, A_2, ..., A_n,要进行两类操作: - 给定一个区间,区间内的每个数都加上一个值,即成段更新; - 区间求和题解线段树。 树中区间对应数字的下标范围,叶子结点从左到右依次代表 A1,A2,...,AnA_1, A_2, ..., A_n 的初始值。 每个节点设两个值: * 子区间的数和,初始时为子区间内初始值原创 2016-05-24 12:33:34 · 349 阅读 · 0 评论