10 2009 档案
摘要:此题经过高人指点之后,使用了离散化DP,从零开始分为左右两边进行DP,将坐标离散化,一个单位一个坐标,先做了一下预处理,记录从零点分别到左(右)某景点至多能访问多少景点;注意分为两个部分求最大值,第一是向左走然后返回看能不能走到原点的右边,如此往返直到不能再走为止,第二和第一一样,只不过是相反方向而已CodeCode highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->#include<iostream>#include<algorith
阅读全文
摘要:思路:一开始使用updte操作,更新到叶子节点,直接导致超时,后来利用截枝,比如tree[root]的区间范围大于要找的范围就截枝,或者tree只有一种颜色就直接返回;其中使用到了位操作,因为颜色总数为30,而int型就有32位,一位可存储一种颜色,这样代码AC,用了297MSCodeCode highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->#include<iostream>usingnamespacestd;constintMAXN=1
阅读全文
摘要://题意:一个人匹配一个房子,使人的移动步伐之和最小//思路:利用KM算法计算二分图最大权匹配AC 0MS,算法一如下:CodeCode highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->#include<iostream>#include<cmath>usingnamespacestd;constintMAXN=102*102/2;constintMAX=-1u>>1;typedefstruct{intx,y;}Po
阅读全文
摘要:CodeCode highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->//在做pku1113时从网上参照来的,贴在这以后好查#include<iostream>#include<algorithm>#include<vector>usingnamespacestd;intmain(){inta[10]={7,4,1,7,4,1,7,4,1,0};sort(a,a+10);//小到大vector<int>ver
阅读全文
摘要:CodeCode highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->//借鉴了一下牛人的程序,终于AC,63MS//题意:求坐标上的点构成的凸包,不过题目有个难点,就是要将wall距离城堡r远,有公式wall=2*pi*r+len(凸包)#include<iostream>#include<cmath>#include<vector>#include<algorithm>usingnamespacestd;
阅读全文
摘要:CodeCode highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->#include<iostream>#include<algorithm>usingnamespacestd;constintMAXN=55;typedefstruct{doublex,y;}Point;Pointp[MAXN];Pointp0={0,0};boolcmp1(constPoint&a,constPoint&b)//y升序,y相同x升
阅读全文
摘要:CodeCode highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->//公式a^2-b^2-c^2+2bccosA=0=>cosA=(b^2+c^2-a^2)/2bc,sinA/a=sinB/b=sinC/c=1/2R#include<iostream>#include<math.h>usingnamespacestd;constdoublepi=acos(-1.0);typedefstruct{doublex,y;}Poi
阅读全文
摘要:CodeCode highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->//题意:给定一张有向图,边有权值,要你计算从min[1N](某点开始到达其他所有点的最短时间的和)//思路:用Floyd做,求两点间的最短距离,时间复杂度为O(N^3)#include<iostream>usingnamespacestd;constintMAXN=102;constintINF=-1u>>1;intmap[MAXN][MAXN];intMax[
阅读全文
摘要:CodeCode highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->//题意:让你给图增加最少的边数,使得一旦图的某条边断掉后其它节点间仍然可达//思路:利用缩图成树的方法,最终算出数的叶子数,(leafnum+1)/2就是答案了#include<iostream>usingnamespacestd;constintMAXN=2010;typedefstruct{//其实起点保存在边的下标中intnext;//该边指向的下一条边编号inte;
阅读全文

浙公网安备 33010602011771号