随笔分类 -  数据结构~树状数组

 
SPOJ - FTOUR2 (点分治+树状数组)
摘要:题目:https://vjudge.net/contest/307753#problem/I 题意:有一颗树,上面有白色黑色点,每个点上有一个权值,权值可以为负,现在我要求一条路径,权值和最大,这条路径满足 白色可以随便经过多少个,黑色点的个数必须<=m 思路:首先又是树上路径题,必然点分治,其实这 阅读全文
posted @ 2019-08-17 14:10 Lis~ 阅读(254) 评论(0) 推荐(0)
AcWing 260. 买票 (树状数组+二分)打卡
摘要:题目:https://www.acwing.com/problem/content/description/262/ 题意:给定一个队伍,每个人过来的时候可以插队,每个人会输入一个插入到哪个位置,但是是按顺序的,所以前面的人选的位置有可能会被后面的人插队抢走,然后问最后的排列是多少 思路:仔细想想其 阅读全文
posted @ 2019-08-09 18:36 Lis~ 阅读(202) 评论(0) 推荐(0)
AcWing 244. 谜一样的牛 (树状数组+二分)打卡
摘要:题目:https://www.acwing.com/problem/content/245/ 题意:有n只牛,现在他们按一种顺序排好,现在知道每只牛前面有几只牛比自己低,牛的身高是1-n,现在求每只牛的身高 思路:我们可以考虑最后一只牛,最后一只牛前面比他低的有 a[n]只,那么他的身高就是 a[n 阅读全文
posted @ 2019-08-06 16:15 Lis~ 阅读(307) 评论(0) 推荐(0)
AcWing 243. 一个简单的整数问题2 (树状数组)打卡
摘要:题目:https://www.acwing.com/problem/content/244/ 题意:区间加,区间查询 思路:我们把原先那个差分数组分解一下 ∑i=1x∑j=1ib[j]=∑i=1x(x−i+1)×b[i]=(x+1)∑i=1xb[i]−∑i=1xi×b[i] #include <bi 阅读全文
posted @ 2019-08-05 21:44 Lis~ 阅读(146) 评论(0) 推荐(0)
AcWing 241. 楼兰图腾 (树状数组)打卡
摘要:题目:https://www.acwing.com/problem/content/description/243/ 题意:给你n个点,问你 V 和 ^的图腾有多少个 思路:比如V 其实就是找当前点左边比自己大的点的个数,右边比自己大的个数,然后乘法原理组合一下,^也是一样的道理 #include< 阅读全文
posted @ 2019-08-05 21:23 Lis~ 阅读(262) 评论(1) 推荐(0)
Codeforces Round #212 (Div. 2) C. Insertion Sort
摘要:C. Insertion Sort Petya is a beginner programmer. He has already mastered the basics of the C++ language and moved on to learning algorithms. The firs 阅读全文
posted @ 2018-08-10 11:57 Lis~ 阅读(361) 评论(0) 推荐(0)
牛客多校第五场 F take
摘要:链接:https://www.nowcoder.com/acm/contest/143/F来源:牛客网 题目描述 Kanade has n boxes , the i-th box has p[i] probability to have an diamond of d[i] size. At th 阅读全文
posted @ 2018-08-03 10:02 Lis~ 阅读(369) 评论(0) 推荐(0)
牛客第二场 J farm
摘要:White Rabbit has a rectangular farmland of n*m. In each of the grid there is a kind of plant. The plant in the j-th column of the i-th row belongs the 阅读全文
posted @ 2018-07-26 10:42 Lis~ 阅读(258) 评论(0) 推荐(0)
树状数组之二维树状数组
摘要:一,二维树状数组之单点修改矩阵查询 我们坐标轴也有一维二维,就是在线得基础上扩展到平面 我们的树状数组也是一样的道理,一维的时候我们存的是一个区间的和 二维就是存的一个矩阵 https://blog.csdn.net/qq_39553725/article/details/76696168 http 阅读全文
posted @ 2018-07-24 19:29 Lis~ 阅读(221) 评论(0) 推荐(0)
树状数组之区间修改单点查询
摘要:树状数组的区间修改单点查询 树状数组其实本质还单点修改区间查询,但是我们怎么延伸到这个呢,我们建立一个差分数组, 比如: a[10]={4, 6, 7, 5, 1, 6, 3, 4, 2, 7} 对应的差分数组 c[10]={4, 2,1,-2,-4, 5,-3, 1,-2, 5} c[i]=a[i 阅读全文
posted @ 2018-07-24 18:50 Lis~ 阅读(335) 评论(0) 推荐(0)
树状数组介绍
摘要:一,前言 之前只会树状数组的一个区间求和,还是记得模板,这次在多校遇到一个用二维树状数组的题,就决心好好把树状数组搞一下,就发现树状数组有很多骚操作。 二,应用 1.树状数组的单点修改区间查询 这个是最常见的树状数组,我们很多书很多博客都是以这个作介绍,下面我也给大家讲一下,首先树状数组也是基于二分 阅读全文
posted @ 2018-07-24 17:00 Lis~ 阅读(201) 评论(0) 推荐(0)