![](https://img-blog.csdnimg.cn/20201014180756928.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
线段树&树状数组&主席树
文章平均质量分 79
elbadaernu
这个作者很懒,什么都没留下…
展开
-
codevs 1080 线段树练习(基本模板 单点修改区间求和)
题目描述 Description 一行N个方格,开始每个格子里都有一个整数。现在动态地提出一些问题和修改:提问的形式是求某一个特定的子区间[a,b]中所有元素的和;修改的规则是指定某一个格子x,加上或者减去一个特定的值A。现在要求你能对每个提问作出正确的回答。1≤N<100000,,提问和修改的总数m<10000条。输入描述 Input Description 输入文件第一行为一个整数N,接下来原创 2017-09-15 11:02:37 · 248 阅读 · 0 评论 -
CodeForces - 597 C. Subsequences(dp+线段树or树状数组优化)
For the given sequence with n different elements find the number of increasing subsequences with k + 1 elements. It is guaranteed that the answer is not greater than 8·1018.Input First line contain tw原创 2017-10-05 11:56:38 · 355 阅读 · 0 评论 -
hdu2227 Find the nondecreasing subsequences(dp+线段树or树状数组优化)
Problem Description How many nondecreasing subsequences can you find in the sequence S = {s1, s2, s3, …., sn} ? For example, we assume that S = {1, 2, 3}, and you can find seven nondecreasing subseque原创 2017-10-05 15:41:08 · 219 阅读 · 0 评论 -
The Battle of Chibi HDU - 5542 (dp+离散化+树状数组优化)
Problem Description Cao Cao made up a big army and was going to invade the whole South China. Yu Zhou was worried about it. He thought the only way to beat Cao Cao is to have a spy in Cao Cao’s army.原创 2017-10-05 17:47:46 · 265 阅读 · 0 评论 -
hdu3450 Counting Sequences(dp+离散化+树状数组优化)
Problem Description For a set of sequences of integers{a1,a2,a3,…an}, we define a sequence{ai1,ai2,ai3…aik}in which 1<= i1 < i2< i3<…< ik<=n, as the sub-sequence of {a1,a2,a3,…an}. It is quite obvious原创 2017-10-05 23:22:57 · 245 阅读 · 0 评论 -
POJ 2155 Matrix(二维树状数组)
DescriptionGiven an N*N matrix A, whose elements are either 0 or 1. A[i, j] means the number in the i-th row and j-th column. Initially we have A[i, j] = 0 (1 <= i, j <= N). We can change the matrix in原创 2017-11-29 01:18:32 · 230 阅读 · 0 评论 -
HDU 4747 Mex(线段树+思维题)
Problem Description Mex is a function on a set of integers, which is universally used for impartial game theorem. For a non-negative integer set S, mex(S) is defined as the least non-negative integer原创 2017-12-08 22:40:44 · 847 阅读 · 0 评论 -
bzoj 3747: [POI2015]Kinoman (线段树+预处理)
Description共有m部电影,编号为1~m,第i部电影的好看值为w[i]。 在n天之中(从1~n编号)每天会放映一部电影,第i天放映的是第f[i]部。 你可以选择l,r(1<=l<=r<=n),并观看第l,l+1,…,r天内所有的电影。如果同一部电影你观看多于一次,你会感到无聊,于是无法获得这部电影的好看值。所以你希望最大化观看且仅观看过一次的电影的好看值的总和。 Input第一行两个整原创 2017-12-12 18:59:22 · 299 阅读 · 0 评论 -
HDU 4777 Rabbit Kingdom(树状数组+离线预处理)
Problem Description Long long ago, there was an ancient rabbit kingdom in the forest. Every rabbit in this kingdom was not cute but totally pugnacious, so the kingdom was in chaos in season and out原创 2017-12-13 02:15:53 · 336 阅读 · 0 评论 -
poj2104 K-th Number (主席树无修改)
DescriptionYou are working for Macrohard company in data structures department. After failing your previous task about key insertion you were asked to write a new data structure that would be able to r原创 2017-12-13 23:52:40 · 303 阅读 · 0 评论 -
hdu 1542 (线段树求矩形面积并)
Problem Description There are several ancient Greek texts that contain descriptions of the fabled island Atlantis. Some of these texts even include maps of parts of the island. But unfortunately, thes原创 2017-09-24 22:28:25 · 257 阅读 · 0 评论 -
poj 2528Mayor's posters(离散化+线段树)
DescriptionThe citizens of Bytetown, AB, could not stand that the candidates in the mayoral election campaign have been placing their electoral posters at all places at their whim. The city council has原创 2017-09-21 01:10:07 · 370 阅读 · 0 评论 -
hdu1394 Minimum Inversion Number(线段树单点修改+区间求和)
Problem Description The inversion number of a given number sequence a1, a2, …, an is the number of pairs (ai, aj) that satisfy i < j and ai > aj.For a given sequence of numbers a1, a2, …, an, if we mo原创 2017-09-15 20:30:02 · 203 阅读 · 0 评论 -
hdu1556 Color the ball(线段树区间修改)
Problem Description N个气球排成一排,从左到右依次编号为1,2,3….N.每次给定2个整数a b(a <= b),lele便为骑上他的“小飞鸽”牌电动车从气球a开始到气球b依次给每个气球涂一次颜色。但是N次以后lele已经忘记了第I个气球已经涂过几次颜色了,你能帮他算出每个气球被涂过几次颜色吗?Input 每个测试实例第一行为一个整数N,(N <= 100000).接下来的N原创 2017-09-16 21:03:40 · 219 阅读 · 0 评论 -
2017 acmicpc 北京网络赛 I Minimum(线段树求区间最值)
描述 You are given a list of integers a0, a1, …, a2^k-1.You need to support two types of queries:Output Minx,y∈[l,r] {ax∙ay}.Let ax=y.输入 The first line is an integer T, indicating the number of test原创 2017-09-23 21:18:27 · 321 阅读 · 0 评论 -
codevs 1217 借教室(线段树区间修改+最值)
题目描述 Description 在大学期间,经常需要租借教室。大到院系举办活动,小到学习小组自习讨论,都需要向学校申请借教室。教室的大小功能不同,借教室人的身份不同,借教室的手续也不一样。面对海量租借教室的信息,我们自然希望编程解决这个问题。我们需要处理接下来n天的借教室信息,其中第i天学校有ri个教室可供租借。共有m份订单,每份订单用三个正整数描述,分别为dj, sj, tj,表示某租借者需要原创 2017-09-18 22:15:10 · 358 阅读 · 0 评论 -
hdu1698 Just a Hook(线段树区间修改)
Problem Description In the game of DotA, Pudge’s meat hook is actually the most horrible thing for most of the heroes. The hook is made up of several consecutive metallic sticks which are of the same原创 2017-09-15 21:40:40 · 228 阅读 · 0 评论 -
hdu1754 I Hate It(线段树单点修改,区间最值)
Problem Description 很多学校流行一种比较的习惯。老师们很喜欢询问,从某某到某某当中,分数最高的是多少。 这让很多学生很反感。不管你喜不喜欢,现在需要你做的是,就是按照老师的要求,写一个程序,模拟老师的询问。当然,老师有时候需要更新某位同学的成绩。Input 本题目包含多组测试,请处理到文件结束。 在每个测试的第一行,有两个正整数 N 和 M ( 0#include<cst原创 2017-09-15 14:29:10 · 246 阅读 · 0 评论 -
codevs 1082 线段树练习 3(区间修改+区间求和)
题目描述 Description 给你N个数,有两种操作:1:给区间[a,b]的所有数增加X2:询问区间[a,b]的数的和。输入描述 Input Description 第一行一个正整数n,接下来n行n个整数,再接下来一个正整数Q,每行表示操作的个数,如果第一个数是1,后接3个正整数,表示在区间[a,b]内每个数增加X,如果是2,表示操作2询问区间[a,b]的和是多少。pascal选手请不要使用原创 2017-09-15 21:57:58 · 242 阅读 · 0 评论 -
poj 3468 A Simple Problem with Integers(线段树区间修改+区间求和)
DescriptionYou have N integers, A1, A2, … , AN. You need to deal with two kinds of operations. One type of operation is to add some given number to each number in a given interval. The other is to ask原创 2017-09-16 22:48:53 · 167 阅读 · 0 评论 -
D-query SPOJ - DQUERY (树状数组离线预处理||主席树)
Given a sequence of n numbers a1, a2, …, an and a number of d-queries. A d-query is a pair (i, j) (1 ≤ i ≤ j ≤ n). For each d-query (i, j), you have to return the number of distinct elements in the sub原创 2017-12-14 22:37:24 · 379 阅读 · 0 评论