线段树树状数组
galesaur_wcy
我们一起加油啊~~~~
展开
-
B - I Hate It(单点更新)(区间求最大值)
B - I Hate It很多学校流行一种比较的习惯。老师们很喜欢询问,从某某到某某当中,分数最高的是多少。 这让很多学生很反感。 不管你喜不喜欢,现在需要你做的是,就是按照老师的要求,写一个程序,模拟老师的询问。当然,老师有时候需要更新某位同学的成绩。 Input 本题目包含多组测试,请处理到文件结束。 在每个测试的第一行,有两个正整数 N 和 M ( 0学生原创 2017-08-08 13:58:40 · 631 阅读 · 0 评论 -
1057 Stack (30)(30 分)
1057 Stack (30)(30 分)Stack is one of the most fundamental data structures, which is based on the principle of Last In First Out (LIFO). The basic operations include Push (inserting an element onto t...转载 2018-08-14 15:38:08 · 321 阅读 · 0 评论 -
A Simple Problem with Integers (线段树区间更新区间求和)
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...原创 2018-05-24 19:35:19 · 230 阅读 · 0 评论 -
sum(树状数组)
sumHey, welcome to HDOJ(Hangzhou Dianzi University Online Judge). In this problem, your task is to calculate SUM(n) = 1 + 2 + 3 + ... + n. Input The input will consist of a series of int原创 2017-08-08 13:59:35 · 251 阅读 · 0 评论 -
A - 敌兵布阵(线段树)(单点更新区间求和)
A - 敌兵布阵C国的死对头A国这段时间正在进行军事演习,所以C国间谍头子Derek和他手下Tidy又开始忙乎了。A国在海岸线沿直线布置了N个工兵营地,Derek和Tidy的任务就是要监视这些工兵营地的活动情况。由于采取了某种先进的监测手段,所以每个工兵营地的人数C国都掌握的一清二楚,每个工兵营地的人数都有可能发生变动,可能增加或减少若干人手,但这些都逃不过C国的监视。中央情报局要研究敌人究竟...原创 2017-08-08 13:56:10 · 262 阅读 · 0 评论 -
H - Color the ball(树状数组)(区间更新)(求单点)(线段树)
H- Color the ballN个气球排成一排,从左到右依次编号为1,2,3....N.每次给定2个整数a b(a <= b),lele便为骑上他的“小飞鸽"牌电动车从气球a开始到气球b依次给每个气球涂一次颜色。但是N次以后lele已经忘记了第I个气球已经涂过几次颜色了,你能帮他算出每个气球被涂过几次颜色吗?Input每个测试实例第一行为一个整数N,(N <=...原创 2017-08-09 13:40:06 · 269 阅读 · 0 评论 -
A - 加农炮(线段树)单点更新
A - 加农炮一个长度为M的正整数数组A,表示从左向右的地形高度。测试一种加农炮,炮弹平行于地面从左向右飞行,高度为H,如果某处地形的高度大于等于炮弹飞行的高度H(Ai >= H),炮弹会被挡住并落在i - 1处,则Ai−1 + 1。如果H 0,则这个炮弹无效,如果H > 所有的Ai,这个炮弹也无效。现在给定N个整数的数组B代表炮弹高度,计算出最后地形的样子。例如:地形原创 2017-08-14 21:19:36 · 156 阅读 · 0 评论 -
线段树总结
http://blog.csdn.NET/shiqi_614/article/details/8228102 之前做了些线段树相关的题目,开学一段时间后,想着把它整理下,完成了大牛NotOnlySuccess的博文“完全版线段树”里的大部分题目,其博文地址Here,然后也加入了自己做过的一些题目。整理时,更新了之前的代码风格,不过旧的代码仍然保留着。转载 2017-08-13 10:20:05 · 224 阅读 · 0 评论 -
线段树(区间更新以及统计片段颜色)
ZOJ - 1610 题目: Painting some colored segments on a line, some previously painted segments may be covered by some the subsequent ones. Your task is counting the segments of different color转载 2017-08-12 15:23:16 · 432 阅读 · 0 评论 -
Buy Tickets (线段树)单点更新
Buy TicketsTime Limit: 4000MS Memory Limit: 65536KTotal Submissions: 20946 Accepted: 10279DescriptionRailway tickets were difficult to buy around the Lunar New Ye转载 2017-08-10 14:35:37 · 169 阅读 · 0 评论 -
C - Just a Hook(线段树)(区间一般更新以及求总和释放懒惰标记)
C - Just a HookIn 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 lengt...原创 2017-08-08 15:40:25 · 254 阅读 · 0 评论 -
树状数组求逆序数
详细见代码#include<bits/stdc++.h>using namespace std;const int maxn = 5000+7;int c[maxn],a[maxn],n;int lowbit(int x){ return x & (-x);}int add(int pos){ for(int i = pos; i <= maxn...原创 2018-12-08 11:15:14 · 119 阅读 · 0 评论