
线段树&树状数组
Baiyi_destroyer
记录过,回望来时路
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
敌兵布阵 (HDU 1166)
C国的死对头A国这段时间正在进行军事演习,所以C国间谍头子Derek和他手下Tidy又开始忙乎了。A国在海岸线沿直线布置了N个工兵营地,Derek和Tidy的任务就是要监视这些工兵营地的活动情况。由于采取了某种先进的监测手段,所以每个工兵营地的人数C国都掌握的一清二楚,每个工兵营地的人数都有可能发生变动,可能增加或减少若干人手,但这些都逃不过C国的监视。 中央情报局要研究敌人究竟演习什么战术,所...原创 2018-07-31 10:59:39 · 277 阅读 · 0 评论 -
树状数组求逆序数
1、什么是逆序数? 在一个排列中,如果一对数的前后位置与大小顺序相反,即前面的数大于后面的数,那么它们就称为一个逆序。一个排列中逆序数的总数就是这个排列的逆序数。 2、用树状数组求逆序数的总数 2.1该背景下树状数组的含义 我们假设一个数组A[n],当A[n]=0时表示数字n在序列中没有出现过,A[n]=1表示数字n在序列中出现过...转载 2018-08-01 15:35:12 · 175 阅读 · 0 评论 -
Japan (POJ 3067)
Japan plans to welcome the ACM ICPC World Finals and a lot of roads must be built for the venue. Japan is tall island with N cities on the East coast and M cities on the West coast (M <= 1000, N &l...原创 2018-08-01 15:24:36 · 380 阅读 · 0 评论 -
Stars (HDU 1541)
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 higher and ...原创 2018-08-01 15:10:16 · 254 阅读 · 0 评论 -
Cows (POJ 2481)
Farmer John's cows have discovered that the clover growing along the ridge of the hill (which we can think of as a one-dimensional number line) in his field is particularly good. Farmer John has N co...原创 2018-08-01 15:00:28 · 538 阅读 · 0 评论 -
树状数组区间加法&区间求和操作
转自:https://www.cnblogs.com/cjyyb/p/8688692.html转载 2018-08-01 09:02:32 · 354 阅读 · 0 评论 -
树状数组(改点求段)
获得x的管理范围:(也可以写作宏定义)int lowbit(int x){ return x&-x;}给x加上k:(不停地找上司,不停地改变,直到到了头)void add(int x,int k){ while(x<=n) { c[x]+=k; x+=lowbit(x); }}求1-x所以元素...原创 2018-08-01 08:44:44 · 192 阅读 · 0 评论 -
Stars (HDU 1541)
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 higher and ...原创 2018-07-31 19:59:12 · 250 阅读 · 0 评论 -
Color the ball(HDU 1556)
N个气球排成一排,从左到右依次编号为1,2,3....N.每次给定2个整数a b(a <= b),lele便为骑上他的“小飞鸽"牌电动车从气球a开始到气球b依次给每个气球涂一次颜色。但是N次以后lele已经忘记了第I个气球已经涂过几次颜色了,你能帮他算出每个气球被涂过几次颜色吗?Input每个测试实例第一行为一个整数N,(N <= 100000).接下来的N行,每行包括2个整数...原创 2018-07-31 14:42:47 · 213 阅读 · 0 评论 -
A Simple Problem with Integers(POJ 3468)
You 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 for the ...原创 2018-07-31 11:19:13 · 146 阅读 · 0 评论 -
Lazy-Tag(线段数思想)
lazy-tag思想,记录每一个线段树节点的变化值,当这部分线段的一致性被破坏我们就将这个变化值传递给子区间,大大增加了线段树的效率。 在此通俗的解释我理解的Lazy意思: 现在需要对[a,b]区间值进行加c操作,那么就从根节点[1,n]开始调用update函数进行更新操作;如果刚好执行到一个rt节点,而且tree[rt].l == a && tree[rt].r == b,这...原创 2018-07-31 11:09:55 · 624 阅读 · 0 评论 -
Just a Hook(HDU 1698)
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 length. Now Pud...原创 2018-07-31 11:02:39 · 243 阅读 · 0 评论 -
I Hate It(HDU 1754)
很多学校流行一种比较的习惯。老师们很喜欢询问,从某某到某某当中,分数最高的是多少。 这让很多学生很反感。 不管你喜不喜欢,现在需要你做的是,就是按照老师的要求,写一个程序,模拟老师的询问。当然,老师有时候需要更新某位同学的成绩。Input本题目包含多组测试,请处理到文件结束。 在每个测试的第一行,有两个正整数 N 和 M ( 0<N<=200000,0<M<5...原创 2018-07-31 11:01:25 · 189 阅读 · 0 评论 -
Minimum Inversion Number (HDU - 1394)
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 move the f...原创 2018-08-02 10:52:15 · 129 阅读 · 0 评论