POJ 1981 Circle and Points (扫描线)】的更多相关文章

Circle and Points Time Limit: 5000MS   Memory Limit: 30000K Total Submissions: 8131   Accepted: 2899 Case Time Limit: 2000MS Description You are given N points in the xy-plane. You have a circle of radius one and move it on the xy-plane, so as to enc…
[题目链接] http://poj.org/problem?id=1981 [题目大意] 给出平面上一些点,问一个半径为1的圆最多可以覆盖几个点 [题解] 我们对于每个点画半径为1的圆,那么在两圆交弧上的点所画的圆,一定可以覆盖这两个点 我们对于每个点计算出其和其它点的交弧,对这些交弧计算起末位置对于圆心的极角, 对这些我们进行扫描线操作,统计最大交集数量就是答案. [代码] #include <cstdio> #include <algorithm> #include <c…
地址:http://poj.org/problem?id=1981 题目: Circle and Points Time Limit: 5000MS   Memory Limit: 30000K Total Submissions: 8198   Accepted: 2924 Case Time Limit: 2000MS Description You are given N points in the xy-plane. You have a circle of radius one and…
转载请注明出处: http://www.cnblogs.com/fraud/          ——by fraud Circle and Points Time Limit: 5000MS   Memory Limit: 30000K Total Submissions: 6850   Accepted: 2443 Case Time Limit: 2000MS Description You are given N points in the xy-plane. You have a cir…
题目链接:http://www.lydsy.com/JudgeOnline/problem.php?id=1338 1338: Pku1981 Circle and Points单位圆覆盖 Time Limit: 3 Sec  Memory Limit: 162 MBSubmit: 190  Solved: 79[Submit][Status][Discuss] Description You are given N points in the xy-plane. You have a circ…
Circle and Points Time Limit: 5000MS   Memory Limit: 30000K Total Submissions: 8346   Accepted: 2974 Case Time Limit: 2000MS Description You are given N points in the xy-plane. You have a circle of radius one and move it on the xy-plane, so as to enc…
Circle and Points Time Limit: 5000MS   Memory Limit: 30000K Total Submissions: 7327   Accepted: 2651 Case Time Limit: 2000MS Description You are given N points in the xy-plane. You have a circle of radius one and move it on the xy-plane, so as to enc…
题意:给定N个点,然后给定一个半径为R的圆,问这个圆最多覆盖多少个点. 思路:在圆弧上求扫描线. 如果N比较小,不难想到N^3的算法. 一般这种覆盖问题你可以假设有两个点在圆的边界上,那么每次产生的圆去看多少个点在园内即可. 但是我们现在要更高效的做法.题目等价于,有N个半径为R的圆,问二维平面上一点最多被多少个圆覆盖.即我们可以每次求交,交的部分标记++: hihocoder1508的代码. #include<bits/stdc++.h> #define pdd pair<double…
[题目链接]:http://poj.org/problem?id=1981 [题意] 给你n个点(n<=300); 然后给你一个半径R: 让你在平面上找一个半径为R的圆; 这里R=1 使得这个圆覆盖的点的数目最多; [题解] 最少会有一个点; 考虑两个点的情况; 枚举任意两个点在圆上; 考虑最极端的情况; 就是这两个点都在圆的边上;(这样圆心就尽可能地远离它们俩了,以求让这个圆覆盖更多的点); 然后求出这个时候这时的圆心的坐标; 然后看看其他的在这个圆内的点的数目就好; 圆心的话只要求一边的圆心…
当两个点距离小于直径时,由它们为弦确定的一个单位圆(虽然有两个圆,但是想一想知道只算一个就可以)来计算覆盖多少点. #include <cstdio> #include <cmath> #define N 301 #define eps 1e-5 using namespace std; int n,ans,tol; double x[N],y[N],dx,dy; inline double sqr(double x) { return x*x; } inline double d…
题目链接:http://poj.org/problem?id=1329 输出很蛋疼,要考虑系数为0,输出也不同 #include<cstdio> #include<cstring> #include<cmath> #include<iostream> #include<algorithm> #include<queue> using namespace std; ; const double PI = acos(-1.0); cons…
题链: http://poj.org/problem?id=1329 题解: 计算几何,求过不共线的三点的圆 就是用向量暴力算出来的东西... (设出外心M的坐标,由于$|\vec{MA}|=|\vec{MB}|=|\vec{MC}|$,可以解出M点坐标.) 代码: #include<cmath> #include<cstdio> #include<cstring> #include<iostream> using namespace std; const…
Circle Through Three Points Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 4112   Accepted: 1712 Description Your team is to write a program that, given the Cartesian coordinates of three points on a plane, will find the equation of the…
题目链接:http://poj.org/problem?id=1329 #include<cstdio> #include<cmath> #include<algorithm> #include<iostream> #include<cstring> using namespace std; typedef long long ll; ; int sgn(double x) { ; ? - : ; } struct Point{ double x…
题目链接 抄的外心模版.然后,输出认真一点.1Y. #include <cstdio> #include <cstring> #include <string> #include <cmath> #include <algorithm> using namespace std; #define eps 1e-8 struct point { double x,y; }; struct line { point a,b; }; point inte…
http://poj.org/problem?id=3090 Visible Lattice Points Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 6153   Accepted: 3662 Description A lattice point (x, y) in the first quadrant (x and y are integers greater than or equal to 0), other…
题目链接:http://poj.org/problem?id=1981 容易想到直接枚举两个点,然后确定一个圆来枚举,算法复杂度O(n^3). 这题还有O(n^2*lg n)的算法.将每个点扩展为单位圆,依次枚举每个单位圆,枚举剩下的单位圆,如果有交点,每个圆产生两个交点,然后对产生的2n个交点极角排序,判断被覆盖最多的弧,被覆盖相当于这个弧上的点为圆心的圆可以覆盖到覆盖它的那些点,所以被覆盖最多的弧就是答案了. O(n^3): //STATUS:C++_AC_4032MS_208KB #inc…
Visible Lattice Points Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 5636   Accepted: 3317 Description A lattice point (x, y) in the first quadrant (x and y are integers greater than or equal to 0), other than the origin, is visible fr…
离散化: 将所有的x轴坐标存在一个数组里..排序.当进入一条线段时..通过二分的方式确定其左右点对应的离散值... 扫描线..可以看成一根平行于x轴的直线..至y=0开始往上扫..直到扫出最后一条平行于x轴的边..但是真正在做的时候..不需要完全模拟这个过程..扫描线的做法是从最下面的边开始扫到最上面的边. 线段树: 本题用于动态维护扫描线在往上走时..x哪些区域是有合法面积的.. 几个图说明扫描线扫描..线段树维护的过程..: 初始状态 扫到最下边的线,点更新1~3为1 扫到第二根线,此时将计…
链接:http://poj.org/problem?id=3090 题意:在坐标系中,从横纵坐标 0 ≤ x, y ≤ N中的点中选择点,而且这些点与(0,0)的连点不经过其它的点. 思路:显而易见,x与y仅仅有互质的情况下才会发生(0,0)与(x,y)交点不经过其它的点的情况,对于x,y等于N时,能够选择的点均为小于等于N而且与N互质的数,共Euler(N)个,而且不重叠.所以能够得到递推公式aa[i]=aa[i]+2*Euler(N). 代码: #include <iostream> #i…
题目链接 Description A number of rectangular posters, photographs and other pictures of the same shape are pasted on a wall. Their sides are all vertical or horizontal. Each rectangle can be partially or totally covered by the others. The length of the b…
[题目链接] http://poj.org/problem?id=3109 [题目大意] 在一个棋盘上放满白子,现在把一些白子变成黑子, 如果一个白子上下左右都有黑子,就会变成黑子,问最终黑子个数 [题解] 首先我们在每列的开头和结尾做标记,之后对行线扫描, 如果是列的开头,那么在该列中标记,如果是列的结尾,则在该列中去除标记 那么我们只要统计行的开头到行的结尾之间夹着多少列标记,且该列下该行没有原来的黑子 就是该行新增的黑子数量,对于总的黑子数量,可以用树状数组统计,之后容斥一下列标记即可.…
Atlantis Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 11777    Accepted Submission(s): 4983 Problem Description There are several ancient Greek texts that contain descriptions of the fabled…
题目大意就是:去一个地方探险,然后给你一些地图描写叙述这个地方,每一个描写叙述是一个矩形的右下角和左上角.地图有些地方是重叠的.所以让你求出被描写叙述的地方的总面积. 扫描线的第一道题,想了又想,啸爷还给我讲了讲,最终有点理解了啊. 先说扫描线:书上说扫描线不是一个物体.而是一个概念. 在计算几何中的作用类似于图论中的bfs与dfs.所以还是须要多做题目来体会一下啊. 这道题目的做法是:离散化x坐标.然后依照y坐标的大小进行排序,每一条保存它的左边界的位置与右边界的位置.以及自身的高度. 还有就…
题目原网址:http://poj.org/problem?id=1177 题目中文翻译: 解题思路: 总体思路: 1.沿X轴离散化建树 2.按Y值从小到大排序平行与X轴的边,然后顺序处理 如果遇到矩形下面那条边则插入到线段树中,遇到矩形上面的边则将相应的边删除掉 根据线段树当前的状态统计长度 第二点是本题的核心思想,偶再举个例:   第一次求出的部分很好理解. 第二次求出的为什么会少了中间那部分.那是因为插入的新线段覆盖了第一条,此时线段树返回的长度是新的那一条的长度,将这个值再减去上次的就少了…
这个题lba等神犇说可以不用离散化,但是我就是要用. 题干: Description There are N, <= N <= , rectangles -D xy-plane. The four sides of a rectangle are horizontal or vertical line segments. Rectangles are defined by their lower-left and upper-right corner points. Each corner p…
http://poj.org/problem?id=3090 http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=1777 题目大意: 给你一个坐标系和一个范围,求x.y在[0,N]这个范围内,未被挡住点的个数. 被挡住的点定义为:从原点引一条射线到某个点,若之前经过其他的点,则被挡住. 思路: 未被挡住的一定是互质的(由斜率可以想到) 然后直接打表吧. #include<cstdio> const int MAXN=1002;…
题目链接 题意:给出n个矩形,每个矩形给左下 和 右上的坐标,求围成的周长的长度. 分析: 首先感谢大神的博客,最近做题经常看大神的博客:http://www.cnblogs.com/kuangbin/ 沿x轴离散化.和之前的矩阵面积并有点像. 但是一定要去重,否则会错 #include <iostream> #include <cstdio> #include <vector> #include <cstring> #include <cstdlib…
题目链接题意:给定n个矩形,求面积并,分别给矩形左上角的坐标和右上角的坐标. 分析: 映射到y轴,并且记录下每个的y坐标,并对y坐标进行离散. 然后按照x从左向右扫描. #include <iostream> #include <cstdio> #include <vector> #include <cstring> #include <cstdlib> #include <algorithm> #define LL __int64…
这是好久之前做过的题,算是在考察欧拉函数的定义吧. 先把欧拉函数讲好:其实欧拉函数还是有很多解读的.emmm,最基础同时最重要的算是,¢(n)表示范围(1, n-1)中与n互质的数的个数 好了,我把规律都放在图上了. 代码就自己写吧.…