上一页 1 ··· 3 4 5 6 7 8 下一页
摘要: 线段树解约瑟夫环,求第i个出圈的人 反素数打的是discuss里的表 Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->#include #include using namespace std; #define MAXN 500001 ... 阅读全文
posted @ 2008-11-08 02:47 Beetlebum 阅读(475) 评论(0) 推荐(0) 编辑
摘要: Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->#include using namespace std; #define MAXN 200001 struct Node{ int l,r,c; }nod[3*MAXN]; in... 阅读全文
posted @ 2008-11-06 23:15 Beetlebum 阅读(283) 评论(0) 推荐(0) 编辑
摘要: 题意:初始化状态为N个含单一元素的集合,动态合并任意两个集合,查询第ith大的集合的大小 分析:以虚二叉树做辅助结构找出第ith大的集合的大小 Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->#include #include using ... 阅读全文
posted @ 2008-11-05 00:37 Beetlebum 阅读(288) 评论(0) 推荐(0) 编辑
摘要: 这题的要求和树状数组的使用方法恰好相反,改变的是一个区间,查询的反而是一个点。我们先看一维的情况。 首先定义 Up(a)={a1=a,a2=a1+lowbit(a1),a3=a2+lowbit(a2) ... } Down(a)={a1=a,a2=a1-lowbit(a1),a3=a2-lowbit(a2) ... } 为了方便讨论,只说明初始化后的第一次“C a b”和“Q c”操作: 对于命令... 阅读全文
posted @ 2008-10-29 23:33 Beetlebum 阅读(452) 评论(0) 推荐(0) 编辑
摘要: 思路: 对结点重编号,使得每棵子树内的结点的编号连续,便可将问题转化为树状数组求区间和, 用后序遍历对整棵树进行重编号能满足要求。 除了要在每个结点处记录新编号tag外,还要记录该结点对应的子树的最小结点编号mn,对 于每个结点x,其苹果个数为sum(x.tag)-sum(x.mn-1)。 Code highlighting produced by Actipro CodeHighlighte... 阅读全文
posted @ 2008-10-29 16:41 Beetlebum 阅读(588) 评论(0) 推荐(0) 编辑
摘要: 这次北京之行的确很值得,黄老师、李老师、path_to_top三人和我走遍了不少地方:北交大、鸟巢、水立方、王府井、清华北大……大家都很尽兴。 而事实上这次区赛大家的表现都不理想(说明咱心里素质比较好)。 差距在Warm Up就已经显现出来了。PTT(以后泛指path_to_top)攻的是B题,这题公式比较难证,但模拟一下就能猜出来了。清华开始几分钟就出了B题,PT... 阅读全文
posted @ 2008-10-28 15:25 Beetlebum 阅读(342) 评论(1) 推荐(0) 编辑
摘要: 题目意思是求一个序列的逆序数,朴素的做法时间复杂度是O(n^2),其中 n #include #include using namespace std; #define MAXN 500005 #define clr(x) memset(x,0,sizeof(x)) int a[MAXN],b[MAXN],c[MAXN],n; __int64 ans; int find(int x){ ... 阅读全文
posted @ 2008-10-22 11:00 Beetlebum 阅读(769) 评论(0) 推荐(0) 编辑
摘要: 思路: 1,对y坐标离散化,设有ycnt个不同的y值,在[0,ycnt]上建立线段树 2,建立竖边结构(每个矩形有两条竖边,n个矩形有2*n条竖边): struct Edge{ int yu;//竖边上端点y坐标 int yd;//下端点y坐标 int x;//x坐标 int tag;//竖边类型 } 把所有竖边分为IN和OUT两类,再对x排序,扫描线遇到IN... 阅读全文
posted @ 2008-10-17 16:52 Beetlebum 阅读(854) 评论(0) 推荐(0) 编辑
摘要: 思路:用位图记录区间已涂上的颜色 Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->#include using namespace std; #define clr(x) memset(x,0,sizeof(x)) #define max(a,... 阅读全文
posted @ 2008-10-16 01:40 Beetlebum 阅读(332) 评论(0) 推荐(0) 编辑
摘要: 思路:在线段树的结点内设5个变量l、r、mx、lf、rf,[l,r]表示该结点的区间范围,lf和rf分别表示元素a[l]和a[r]在区间内的出现频率,mx表示区间内的最高出现频率。 假设区间[x,y]和[y+1,z]均被询问[i,j]覆盖,则可以分情况讨论区间[x,z]的mx值: 若a[y]==a[y+1],则mx[x,y]=max{mx[x,y],mx[y+1,z],rf[x,y]+lf[y+1... 阅读全文
posted @ 2008-10-15 19:34 Beetlebum 阅读(570) 评论(1) 推荐(0) 编辑
上一页 1 ··· 3 4 5 6 7 8 下一页