![](https://img-blog.csdnimg.cn/20201014180756923.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
Binary Indexed Tree
Feynman1999
理论都是灰色的,而生活之树常青^_^
展开
-
BIT(树状数组简介)
引言 有一组数,比如说n个,任务是支持一个查询操作Query(L,R):计算L到R区间的和。 如果每次循环来计算,每一个询问计算的复杂度是O(n)O(n)的,时间上不能接受。 考虑前缀和的思想,先O(n)O(n)预处理出前缀和,对于每次查询可以O(1)O(1)解决。 但如果可修改呢?比如可以修改某个元素的值,这时候前缀和失效,如果重新维护,时间上不能接受。 下面要介绍的树状数组(Bin原创 2018-01-16 11:43:11 · 1965 阅读 · 0 评论 -
HRBUST - 2224 逆序对数(树状数组)
problem 给定 n 个数组成的数组,求其逆序对的总数。 逆序对定义为,存在 (i, j) 满足 i < j 且 A[i] > A[j] 的二元组的数目。 Input 第一行包含一个整数,表示数组的项数。 接下来的一行,包含 n 个数(2 <= n <= 100000),依次表示 A[i](A[i] <= 10^9)。 Output 输出一行...原创 2018-03-29 19:15:14 · 490 阅读 · 0 评论 -
poj 2352(树状数组)
problem Astronomers often examine star maps where stars are represented by points on a plane and each star has Cartesian coordinates. Let the level of a star be an amount of the stars that are not hi...原创 2018-03-29 21:54:47 · 162 阅读 · 0 评论