码迷,mamicode.com
首页 >  
搜索关键字:树状    ( 5251个结果
BZOJ 1878 [SDOI2009]HH的项链 离线+树状数组
BZOJ 1878 [SDOI2009]HH的项链 离线+树状数组...
分类:编程语言   时间:2015-05-06 15:10:36    阅读次数:141
poj 2352 Stars 树状数组
树状数组,果断1A啦,心情舒畅啊,哈哈先依照y轴从小到大排序,然后一次增加并统计每一个点得x坐标,这道题数据不严谨啊,在y轴同样得情况下,应该以x轴从大到小排序,可我都没排x轴就过了#include#include#include#includeusing namespace std;int Max...
分类:编程语言   时间:2015-05-06 14:41:31    阅读次数:146
VIJOS 1512SuperBrother打鼹鼠(二维BIT)
呵呵..二维树状数组,第二维和第一维基本一样.--------------------------------------------------------------------------------#include#include#include#include#define rep(i, ...
分类:其他好文   时间:2015-05-05 19:02:52    阅读次数:131
POJ 2299 Ultra-QuickSort
题意:问给一堆数排序要交换多少次……这个排序方法读题的时候没看出来是什么……后来百度了一下说是冒泡,也就是说这是一个求逆序数的题。解法:求逆序数有三种方法,线段树,树状数组,归并排序。以上三种方法是按我做的顺序排的,实际最优的是归并和树状数组,线段树有常数。线段树:首先要离散化处理,离散化的方法是给...
分类:其他好文   时间:2015-05-05 18:50:05    阅读次数:125
HUST-1407 郁闷的小J
离线做法:分别处理每个编号上的各种询问和操作,接着就能用树状数组维护。#include #include #include #include #include #include #include #define rep(i, l, r) for(int i=l; i0) now+=s(x), x-=...
分类:其他好文   时间:2015-05-05 18:37:21    阅读次数:124
BZOJ 1901 Dynamic Rankings
数据结构模版题【连这么神的题都沦为模版题了Orz对数离散化后树状数组套权值线段树。#include #include #include #include #include #include #include #define rep(i, l, r) for(int i=l; il=t->r=blan...
分类:其他好文   时间:2015-05-05 18:19:19    阅读次数:98
树状数组【模板】
Tree[N] = A[N-2^k+1] + … + A[N] 单点更新,区间求值:树状数组代表区间的和。const int MAXN = 100010; int N,Tree[MAXN];int Lowbit(int i) { return i & (-i); }void Update(int i,int x) { while(i <= N) { Tree...
分类:编程语言   时间:2015-05-05 08:53:55    阅读次数:163
Codeforces276E:Little Girl and Problem on Trees
A little girl loves problems on trees very much. Here's one of them. A tree is an undirected connected graph, not containing cycles. The degree of node x in the tree is the number of nodes y of t...
分类:其他好文   时间:2015-05-05 01:22:29    阅读次数:183
bzoj-1878 HH的项链
题意: 给定长为n的序列与m个询问; 求询问的区间里不相同数字的个数; n 题解: 在线算法太过高深并不会,所以这道题就要离线做; 分析数据范围,m个询问完全可以存下,1000000的数字也可以hash勉强不用离散化; 那么考虑一段区间的数字种类数,大概就是 1 - R 减去 1 - ( L - 1 ) ; 但是因为有重复的数字,对于重复了的数,我们只应该在L-R间计算...
分类:其他好文   时间:2015-05-04 08:47:16    阅读次数:165
Codeforces Round #301 (Div. 2)(树状数组+离散化)
E. Infinite Inversions time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output There is an infinite sequence consis...
分类:编程语言   时间:2015-05-04 01:17:26    阅读次数:222
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!