![](https://img-blog.csdnimg.cn/20201014180756754.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
线段树
SSimpLe_Y
人一我百,人十我万,然而我做不到。
展开
-
lightoj 1135 - Count the Multiples of 3(线段树)
You have an array with n elements which is indexed from 0 to n - 1. Initially all elements are zero. Now you have to deal with two types of operations1. Increase the numbers between indices i a原创 2017-01-28 17:52:32 · 858 阅读 · 0 评论 -
Codeforces Round #426 (Div. 2) D. The Bakery(DP+线段树)
Some time ago Slastyona the Sweetmaid decided to open her own bakery! She bought required ingredients and a wonder-oven which can bake several types of cakes, and opened the bakery.Soon the expens原创 2017-07-31 09:16:44 · 1747 阅读 · 0 评论 -
线段树--单点更新
hdu 1166 敌兵布阵第一行一个整数T,表示有T组数据。 每组数据第一行一个正整数N(N接下来每行有一条命令,命令有4种形式: (1) Add i j,i和j为正整数,表示第i个营地增加j个人(j不超过30) (2)Sub i j ,i和j为正整数,表示第i个营地减少j个人(j不超过30); (3)Query i j ,i和j为正整数,i(4)End 表示结束,这条原创 2016-05-24 16:42:35 · 367 阅读 · 0 评论 -
线段树--区间更新
按区间build树,就是为了说明一下向下更新。#include#include#includeusing namespace std;const int maxn = 100010;int sum[maxn*4];int add[maxn*4];void PushUp(int rt){ sum[rt] = sum[rt*2] + sum[rt*2+1];}void原创 2016-05-24 17:06:56 · 396 阅读 · 0 评论 -
bzoj 2733: [HNOI2012]永无乡(线段树启发式合并)
Description永无乡包含 n 座岛,编号从 1 到 n,每座岛都有自己的独一无二的重要度,按照重要度可 以将这 n 座岛排名,名次用 1 到 n 来表示。某些岛之间由巨大的桥连接,通过桥可以从一个岛 到达另一个岛。如果从岛 a 出发经过若干座(含 0 座)桥可以到达岛 b,则称岛 a 和岛 b 是连 通的。现在有两种操作:B x y 表示在岛 x 与岛 y 之间修建一座新桥。Q原创 2017-08-31 21:35:34 · 821 阅读 · 0 评论 -
Codecraft-18 and Codeforces Round #458 D. Bash and a Tough Math Puzzle(线段树)
Bash likes playing with arrays. He has an array a1, a2, ... an of n integers. He likes to guess the greatest common divisor (gcd) of different segments of the array. Of course, sometimes the guess i原创 2018-01-21 13:22:11 · 1216 阅读 · 0 评论