09 2013 档案
hdu 1077 (圆交)
摘要:Problem - 1077 我们可以知道,当这个单位圆可以覆盖到最多的点的时候,必定最少有两个点位于这个圆的圆周上,于是就有网上众多的O(N^3)的枚举两个在圆上的点的暴搜做法。 然而这题是可以用圆交来做的。 我们以一条鱼的位置作为圆心,半径为1的圆的周围随便找一个点都能把这条鱼抓到。这时,我们可
阅读全文
hdu 4629 Burning (扫描线)
摘要:Problem - 4629 以前写过PSLG模拟的版本,今天写了一下扫描线做这题。 其实这题可以用set存线段来做,类似于判断直线交的做法。不过实现起来有点麻烦,于是我就直接暴力求交点了。代码如下: 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 #include 9 10 using namespace std; 11 12 const double EPS = 1e-10; 13 inline int sgn(double x) { re...
阅读全文
SPOJ 8073 The area of the union of circles (圆并入门)
摘要:Sphere Online Judge (SPOJ) - Problem CIRU【求圆并的若干种算法,圆并扩展算法】_AekdyCoin的空间_百度空间 参考AekdyCoin的圆并算法解释,根据理解写出的代码。圆并这么多题中,最基础一题。 操作如下:(1)对一个圆,获得所有与其他圆的交点作为时间戳。 a.如果这个圆不被其他任何圆覆盖,这个圆直接保留。 b.如果Case中有两个完全重合的圆,可以保留标号小(或大)的圆,也只保留这一个。(2)每经过一个时间戳就对计数器加减,如果计数器从0变1,加上这段圆弧和对应的三角形。(3)所有这样的圆独立计算,最后求出的面积累加即可。代码如下(1y...
阅读全文
4818 Largest Empty Circle on a Segment (几何+二分)
摘要:ACM-ICPC Live Archive 挺水的一道题,直接二分圆的半径即可。1y~ 类似于以前半平面交求核的做法,假设半径已经知道,我们只需要求出线段周围哪些位置是不能放置圆心的即可。这样就转换为圆与直线,直线与直线交的问题了。 不知道这题能不能SAA过,有空试下。代码如下: 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 8 using namespace std; 9 10 const double EPS = 1e-5; 11 inline int sgn(...
阅读全文
树状数组(Binary Index Tree)
摘要:一维BIT(单点更新,区间求和):Problem - 1166 1 #include 2 #include 3 #include 4 #include 5 6 using namespace std; 7 8 const int N = 111111; 9 typedef long long LL;10 inline int lowbit(int x) { return x & -x;}11 struct BIT {12 LL s[N], sz;13 void init(int n) { sz = n; for (int i = 1; i 0; x -= lowb...
阅读全文
hdu 4128 Running relay (线性规划转半平面交)
摘要:Problem - 4128 对偶线性规划转半平面交,这题的正解O(nlogn)解法,目前网上没有找到这样的正解。 原来的不等式组,sigma{-si*xi}>=-W+d*sigma{si}sigma{xi}>=L-n*dsigma{-xi}>=-L+n*dxi>=0T=sigma{ti*xi}+d*sigma{ti},求Min(T)。 用线性规划对偶性,变成了-si*x+y=0,y无限制T'=(-W+d*sigma(si))*x+(L-nd)*y+d*sigma{ti},求Max(T')。——written by Lyon
阅读全文
浙公网安备 33010602011771号