码迷,mamicode.com
首页 >  
搜索关键字:树状数组 逆序数    ( 4158个结果
二维树状数组
Mobile phoneshttp://poj.org/problem?id=1195 1 #include 2 #include 3 #define mt(a,b) memset(a,b,sizeof(a)) 4 const int M=1030; 5 class Two_Tree_Array {...
分类:其他好文   时间:2014-08-01 13:03:01    阅读次数:168
hdu1394--Minimum Inversion Number(线段树求逆序数,纯为练习)
Minimum Inversion Number Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 10326 Accepted Submission(s): 6359 Problem Description The invers...
分类:其他好文   时间:2014-08-01 00:08:10    阅读次数:299
POJ 1195 Mobile phones (二维树状数组)
题目大意: 对一个矩阵上的某个值进行修改,然后求出子矩阵的和。 思路分析: 这题discuss 上说二维线段树过不了。 所以二维树状数组搞。 理解树状数组的意义就是 1 - n 上所有的和。 然后两重循环。 #include #include #include #include #define maxn 1040 #define lowbit(x) (x&(-...
分类:其他好文   时间:2014-07-31 20:46:37    阅读次数:201
HDU - 1394 Minimum Inversion Number (线段树求逆序数)
Description The inversion number of a given number sequence a1, a2, ..., an is the number of pairs (ai, aj) that satisfy i aj. For a given sequence of numbers a1, a2, ..., an, if we move the ...
分类:其他好文   时间:2014-07-31 13:31:46    阅读次数:229
SPOJ DQUERY D-query 离线+树状数组
本来是想找个主席树的题目来练一下的,这个题目虽说可以用主席树做,但是用这个方法感觉更加叼炸天第一次做这种离线方法,所谓离线,就在把所有询问先存贮起来,预处理之后再一个一个操作像这个题目,每个操作要求区间不同元素的个数,我盲目去查的话,某个元素在之前如果出现了,我把他算在当前区间也不好,算在之前的区间...
分类:其他好文   时间:2014-07-31 02:19:05    阅读次数:252
UVA 11525 - Permutation(树状数组)
UVA 11525 - Permutation 题目链接 题意:给定一个k个数字,求第n个全排列,由于n很大,输入的方式为∑k1Si?(K?i)! 思路:全排列,很容易看出,前面的si对应的就是数组中第k小的数字,那么问题变成每次找第k小的数字,然后去掉这个数字,这个用树状数组很容易实现 代码: #include #include #define lowbit(...
分类:其他好文   时间:2014-07-30 17:25:44    阅读次数:167
UVA 1513 - Movie collection(树状数组)
UVA 1513 - Movie collection 题目链接 题意:有一些光盘,一开始是n-1叠上去的(1最顶),现在每次抽出一张,要问这一张上面有多少张,然后把抽出来这张放到最顶,输出每次询问 思路:树状数组,数组维护每个位置下面有多少张光碟,这样每次拿出一张,就在相应位置-1就可以了,然后在最顶位置上多一个位置+1 代码: #include #include...
分类:其他好文   时间:2014-07-30 14:45:33    阅读次数:186
怒刷30道线段树、树状数组
HDU 1754 单点更新,区间查询最大值,水题…… #include #include #include #include #include #include #include #include #include #define mem(a,b) memset(a,b,sizeof(a)) #define lson i<<1,l,mid #define rson i<<1|1,mid+1,r...
分类:其他好文   时间:2014-07-30 12:23:33    阅读次数:252
Ultra-QuickSort(树状数组 + 离散化)
Description In this problem, you have to analyze a particular sorting algorithm. The algorithm processes a sequence of n distinct integers by swapping two adjacent sequence elements until the seq...
分类:其他好文   时间:2014-07-30 12:22:33    阅读次数:290
【HDU1394】Minimum Inversion Number(线段树)
大意:n次操作原串查询逆序数,求出所有串中最小的逆序数。求逆序数属于线段树的统计问题,建立空树,每次进行插点时进行一次query操作即可。n次操作可以套用结论:如果是0到n的排列,那么如果把第一个数放到最后,对于这个数列,逆序数是减少a[i],而增加n-1-a[i]。 1 #include 2 #....
分类:其他好文   时间:2014-07-30 09:46:43    阅读次数:163
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!