摘要:
http://acm.hdu.edu.cn/showproblem.php?pid=1542 单纯的线段树+扫描线求面积并,需要离散化。code:#include<cstdlib>#include<cctype>#include<cstring>#include<cstdio>#include<cmath>#include<algorithm>#include<vector>#include<string>#include<iostream>#include<sstream>
阅读全文
posted @ 2012-08-22 09:08
追逐.
阅读(292)
推荐(0)
摘要:
http://acm.hdu.edu.cn/showproblem.php?pid=1394 线段树求逆序数,先求出初始数组的逆序数(n logn),然后o(1)推出其他逆序数。因为输入为0--n-1,所以建树从0开始。code:#include<cstdlib>#include<cctype>#include<cstring>#include<cstdio>#include<cmath>#include<algorithm>#include<vector>#include<string>#incl
阅读全文
posted @ 2012-08-20 09:37
追逐.
阅读(240)
推荐(0)
摘要:
http://acm.hdu.edu.cn/showproblem.php?pid=1541 开始知道是用树状数组做,但想了好半天不知道怎么用,总觉得要先排序才能做。但是排序的话复杂度就上去了啊。 纠结了半天才读到那句Stars are listed in ascending order of Y coordinate.擦了个擦的,早看见不完了。 c[pos]表示1到pos的和,也就是当前星星前有几个(包含当前)。用cnt记录各等级数量。code:#include<cstdlib>#include<cctype>#include<cstring>#inclu
阅读全文
posted @ 2012-08-07 20:15
追逐.
阅读(316)
推荐(0)
摘要:
http://acm.hdu.edu.cn/showproblem.php?pid=1166 相比与线段树,树状数组的编程难度确实很低,不容易出错,而且同等问题上效率较高些。 但是好像树状数组能解决的问题线段树都可以解决,而线段树能解决的它却不一定能解决。code:#include<cstdlib>#include<cctype>#include<cstring>#include<cstdio>#include<cmath>#include<algorithm>#include<vector>#include&
阅读全文
posted @ 2012-08-07 12:20
追逐.
阅读(195)
推荐(0)
摘要:
http://poj.org/problem?id=2104 入门的划分树,说实话一开始看着挺晕的,真看明白了,知道了各个操作各个变量的意义就简单多了。 这个有没有线段树的解法?既然是基于线段树的,那么处理这种问题就应该比线段树的复杂度低很多吧。code:#include<cstdlib>#include<cctype>#include<cstring>#include<cstdio>#include<cmath>#include<algorithm>#include<vector>#include<st
阅读全文
posted @ 2012-08-06 17:59
追逐.
阅读(429)
推荐(0)
摘要:
二维线段树,用的树套树,在第一维每个节点上再建一个线段树,代码量加倍。code:#include<cstdlib>#include<cctype>#include<cstring>#include<cstdio>#include<cmath>#include<algorithm>#include<vector>#include<string>#include<iostream>#include<sstream>#include<set>#include<qu
阅读全文
posted @ 2012-08-05 15:05
追逐.
阅读(1421)
推荐(0)
摘要:
区间更新用到的延迟标记,不过是在更新时只更新到最大父区间,不继续往下更新,把更新的状态记录下来。当访问到子区间时再根据相应记录及时更新,pushodown()。code:#include<cstdlib>#include<cctype>#include<cstring>#include<cstdio>#include<cmath>#include<algorithm>#include<vector>#include<string>#include<iostream>#include<
阅读全文
posted @ 2012-07-31 12:28
追逐.
阅读(545)
推荐(0)
摘要:
发现这本书写的确实不错,通过刚大学毕业的小菜和大鸟之间的对话模式,深入浅出地从实际问题出发,层层推进软件设计模式。文章从一个大学生笔试题讲起,也让我想起了自己的笔试经历,其实发现自己自从大学毕业之后,就没有再学习过太多的理论,做的都是实验室里的小打小闹的小软件,面对每次实验的时候,一帮研究数据的所谓物理学家,对软件或这或那的需求变化,再加上1个多月公司的实习经历,让我真切感受到设计模式的重要。发现自己还停留在ctrl+c,ctrl+v的水平,呵呵。也许一直以来所处的环境让我没有意识到这点吧,这次实习经历感觉真是收获颇多,至少知道了设计模式在软件开发、维护过程中的重要性。 下面就结合自己看的..
阅读全文
posted @ 2012-06-27 13:52
追逐.
阅读(296)
推荐(0)
摘要:
1. 数字三角形,POJ1163,不多说。code:#include<cstdio>#include<iostream>#include<cstring>#include<fstream>#include<cstdlib>#include<memory>#include<algorithm>#definereadfreopen("numtri.in","r",stdin)#definewritefreopen("numtri.out","w&
阅读全文
posted @ 2012-05-23 17:45
追逐.
阅读(174)
推荐(0)
摘要:
1. 恶心的题..考虑了很久没好的想法,看了下报告,直接按图处理即可!搞毛啊,为什么能保证图示能包含所有情况??枚举每个矩形位置和放置情况时用了next_permutation(),next_permutation()是生成下一字典序最小的排列,不包含当前排列,所以一般用do..while()语句。code:#include<cstdio>#include<iostream>#include<cstring>#include<fstream>#include<cstdlib>#include<memory>#include
阅读全文
posted @ 2012-05-23 17:33
追逐.
阅读(167)
推荐(0)