Shirlies
宁静专注认真的程序媛~
posts - 222,comments - 49,views - 71万

随笔分类 -  acm_线段树

hdu 1754【I Hate It】
摘要:一道简单的线段树题目,好久没有刷题,偶来刷刷,除了刚开始提交RE了,原因是segtree数组开的太小了,一改大就A了,本来代码是用vim写的,用G++编译,结果老是报错,错的都很离谱,就改用code::blocks编译@_@。。。再去研究下G++。。。代码如下: 1 #include <cstdio> 2 #include <algorithm> 3 4 const int maxlen = 200000+10; 5 int scores[maxlen]; 6 7 struct node 8 { 9 int left,right; 10 int value... 阅读全文
posted @ 2013-03-20 19:41 Shirlies 阅读(185) 评论(1) 推荐(0) 编辑
hdu 1394【Minimum Inversion Number】
摘要:线段树假如考虑iValue[i],则要先将iValue[1]->iValue[i-1]放在线段树里面,计算每一段里面包含多少个已遍历值(iValue[1]->iValue[i-1]),然后查找iValue[i]+1->n的值有多少个,这样的话,就相当与在查找iValue[1]->iValue[i-1]有多少个值是在iValue[i]+1->n范围的。(这一题目也可以用树状数组做)代码如下: 1 #include <iostream> 2 3 using namespace std; 4 5 struct node 6 { 7 int low,high; 阅读全文
posted @ 2012-12-01 12:43 Shirlies 阅读(206) 评论(0) 推荐(0) 编辑
hdu 1264【Counting Squares】
摘要:一道线段树的题目,由于之前没怎么做过线段树的题目,这道题我觉得还是有点小难的首先将x坐标排序,然后找相邻的x坐标之间的最大y值和最小y值,这些矩形是要覆盖x,x+1坐标的,然后将yMax,yMin分散到线段树上,并用一个值标记哪些节点被分布了,最后查找一遍就可以了。代码如下: 1 #include <iostream> 2 #include <algorithm> 3 #include <cstring> 4 using namespace std; 5 6 int X_axle[20000]; 7 8 struct node 9 { 10 int xLow 阅读全文
posted @ 2012-11-29 14:24 Shirlies 阅读(333) 评论(0) 推荐(0) 编辑

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

点击右上角即可分享
微信分享提示