![](https://img-blog.csdnimg.cn/20201014180756928.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
线段树
文章平均质量分 64
小冷在努力
这个作者很懒,什么都没留下…
展开
-
hdu oj 1698 just a hook 线段树
题意分析: 一道有关线段树区间修改的入门题。线段树区间修改一般包含两个操作:设有一个数组Ai。1.把Ai,Ai+1,Ai+2....Ar的值全部添加v。2.把Ai,Ai+1,Ai+2....Ar的值全部修改成v.这道题考查的石第二个操作。如果你要是明白了线段树的点修改,这道题你看别人写的代码,你很容易就能明白。我就是一个活生生的例子。如果这道题你看明白了,我们可以想一下如果给你一道题,有关第一个原创 2014-12-21 14:28:42 · 514 阅读 · 0 评论 -
poj 2182 :Lost Cows (线段树)
这道题说是线段树,其实题意理解之后,分析可知:比最后一头牛的编号小的数为x,则这头牛的编号为x+1,比倒数第二投牛的编号小的数为y,则去掉所知牛的编号后,剩下的编号按从小到大的顺序数到第y+1个即刻。即:每次可以先知道最后一头牛的编号。 未用到线段树的代码:#include #include #include using namespace std; int main() { int s[80原创 2015-03-15 10:00:39 · 296 阅读 · 0 评论 -
poj 3264 Balanced Lineup 线段树
这道题是线段树的入门提,但是这道题对递归的理解要求比较高。 代码如下: #include #include #include #include using namespace std; struct node { int lc,rc,mi,ma; }s[50010000]; int a[50010],mi=10000000,ma=-10; void build(int left,int r原创 2015-03-17 22:08:20 · 251 阅读 · 0 评论