码迷,mamicode.com
首页 >  
搜索关键字:线段树    ( 9365个结果
POJ 3321 Apple Tree (dfs+线段树)
题目大意: 修改树上的节点,然后求子树的和。 思路分析: dfs 重新编号,烂大街了。。。 #include #include #include #include #define maxn 100005 #define lson num<<1,s,mid #define rson num<<1|1,mid+1,e using namespace std; int num[...
分类:移动开发   时间:2014-07-31 20:46:27    阅读次数:251
HDU 1166
线段树 1 #include 2 #include 3 using namespace std; 4 #define N 200010 5 int sum[N]; 6 void build(int l,int r,int root){ 7 if(l==r)scanf("%d",&sum...
分类:其他好文   时间:2014-07-31 16:21:47    阅读次数:200
HDU 1698
线段树,懒惰标记 1 #include 2 #include 3 using namespace std; 4 #define N 400010 5 int sum[N],lazy[N]; 6 void pushup(int root){ 7 sum[root]=sum[root*2]+...
分类:其他好文   时间:2014-07-31 16:07:46    阅读次数:255
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
POJ--2528--Mayor's posters【线段树+离散化】
题意:在一块木板上贴海报,每次贴海报给一个横坐标范围,在这个范围内贴,按照它给的顺序,海报可以被覆盖,问最后还能看见几张海报。 都说这是线段树入门题。。。。结果我还是出翔了,不是在线段树部分,是在离散化部分。 我之前看到一个很飘逸的离散化写法,可惜找不到了,这回是这么写的:去重之后再把每个点的后一个值也加入离散化后的数组(如果这个值之前没有的话),这样避免了漏掉中间没被覆盖的情况。 ...
分类:其他好文   时间:2014-07-31 13:30:06    阅读次数:164
poj 2823 Sliding Window 单调队列或线段树
题目链接:http://poj.org/problem?id=2823 Sliding Window Time Limit: 12000MS   Memory Limit: 65536K Total Submissions: 38315   Accepted: 11350 Case Time Limit: 5000MS...
分类:Windows程序   时间:2014-07-31 13:26:26    阅读次数:308
HDU 4893 线段树的 点更新 区间求和
Wow! Such Sequence!Time Limit: 10000/5000 MS (Java/Others)Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 2067Accepted Submission(s): 61...
分类:其他好文   时间:2014-07-31 12:38:26    阅读次数:310
HDU 1698 Just a Hook (线段树区间更新)
题目链接题意 : 一个有n段长的金属棍,开始都涂上铜,分段涂成别的,金的值是3,银的值是2,铜的值是1,然后问你最后这n段总共的值是多少。思路 : 线段树的区间更新。可以理解为线段树成段更新的模板题。 1 //HDU 1698 2 #include 3 #include 4 #include ...
分类:其他好文   时间:2014-07-31 12:37:26    阅读次数:264
HDU 1754
第一题线段树,纪念一下 1 #include 2 #include 3 using namespace std; 4 int tree[800005]; 5 void build(int l,int r,int root){ 6 if(l==r){ 7 scanf("%...
分类:其他好文   时间:2014-07-31 12:23:06    阅读次数:208
线段树心得
核心知识点:(i)如何构造一颗线段树:void build(int rt,int L,int R){ if(L==R) scanf("%d",&Max[rt]); else { int M=(L+R)/2; build(rt*2,L,M); build...
分类:其他好文   时间:2014-07-31 12:09:06    阅读次数:308
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!