题意:给定N个点,然后给定一个半径为R的圆,问这个圆最多覆盖多少个点。

思路:在圆弧上求扫描线。

如果N比较小,不难想到N^3的算法。 一般这种覆盖问题你可以假设有两个点在圆的边界上,那么每次产生的圆去看多少个点在园内即可。

但是我们现在要更高效的做法。题目等价于,有N个半径为R的圆,问二维平面上一点最多被多少个圆覆盖。即我们可以每次求交,交的部分标记++;

hihocoder1508的代码。

#include<bits/stdc++.h>
#define pdd pair<double,int>
#define f first
#define s second
#define rep(i,a,b) for(int i=a;i<=b;i++)
using namespace std;
const int maxn=;
const double eps=1e-;
const double pi=acos(-1.0);
struct point{ double x,y;}p[maxn];
double det(point a,point b){ return a.x*b.y-a.y*b.x;}
double dot(point a,point b){ return a.x*b.x+a.y*b.y;}
point operator +(point a,point b){ return point{a.x+b.x,a.y+b.y}; }
point operator -(point a,point b){ return point{a.x-b.x,a.y-b.y}; }
double dist(point a,point b){ return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));}
int dcmp(double x){ if(fabs(x)<eps) return ; return x>?:-;}
pdd a[maxn]; int ans,N; double ang1,ang2,R;
void CirinterCir(point a,point b)
{
double L=dist(a,b)/,t=acos(L/R);
double base=atan2(b.y-a.y,b.x-a.x);
ang1=base+t,ang2=base-t;
}
bool check(point i,point j)
{
double ang=(ang1+ang2)/;
point x=point{i.x+R*cos(ang),i.y+R*sin(ang)};
return dcmp(dist(x,j)-R)<=;
}
void solve()
{
rep(i,,N) {
int cnt=,Mx,tot=;
rep(j,,N) {
if(i==j||dist(p[i],p[j])>R+R) continue;
if(p[i].x==p[j].x&&p[i].y==p[j].y) { cnt++; continue;}
CirinterCir(p[i],p[j]);
if(ang1>ang2) swap(ang1,ang2);
if(check(p[i],p[j])){
a[++tot]=pdd(ang1-eps,-);
a[++tot]=pdd(ang2,);
}
else {
a[+tot]=pdd(-pi-eps,-);
a[++tot]=pdd(ang1,);
a[++tot]=pdd(ang2-eps,-);
a[++tot]=pdd(pi,);
}
}
sort(a+,a+tot+); Mx=cnt;
rep(i,,tot){
if(a[i].s==-) cnt++;
else cnt--;
Mx=max(Mx,cnt);
}
ans=max(ans,Mx);
}
}
int main()
{
scanf("%d%lf",&N,&R);
rep(i,,N) scanf("%lf%lf",&p[i].x,&p[i].y);
solve();
printf("%d\n",ans);
return ;
}

POJ - 1981 :Circle and Points (圆的扫描线) hihocoder1508的更多相关文章

  1. poj 1981 Circle and Points

    Circle and Points Time Limit: 5000MS   Memory Limit: 30000K Total Submissions: 8131   Accepted: 2899 ...

  2. POJ 1981 Circle and Points (扫描线)

    [题目链接] http://poj.org/problem?id=1981 [题目大意] 给出平面上一些点,问一个半径为1的圆最多可以覆盖几个点 [题解] 我们对于每个点画半径为1的圆,那么在两圆交弧 ...

  3. poj1981 Circle and Points

    地址:http://poj.org/problem?id=1981 题目: Circle and Points Time Limit: 5000MS   Memory Limit: 30000K To ...

  4. poj1981 Circle and Points 单位圆覆盖问题

    转载请注明出处: http://www.cnblogs.com/fraud/          ——by fraud Circle and Points Time Limit: 5000MS   Me ...

  5. bzoj1338: Pku1981 Circle and Points单位圆覆盖

    题目链接:http://www.lydsy.com/JudgeOnline/problem.php?id=1338 1338: Pku1981 Circle and Points单位圆覆盖 Time ...

  6. HDU5299 圆的扫描线 && 树上删边博弈

    HDU5299 圆的扫描线 && 树上删边博弈 标签(空格分隔): 未分类 给出若干个圆,可以互相嵌套但不相交或相切. 每次删去一个圆和它内部的圆,进行博弈,问谁赢. 分成两部分.首先 ...

  7. POJ 1981 最大点覆盖问题(极角排序)

    Circle and Points Time Limit: 5000MS   Memory Limit: 30000K Total Submissions: 8346   Accepted: 2974 ...

  8. hdu3511 Prison Break 圆的扫描线

    地址:http://acm.split.hdu.edu.cn/showproblem.php?pid=3511 题目: Prison Break Time Limit: 10000/5000 MS ( ...

  9. poj 1981(单位圆覆盖最多点问题模板)

    Circle and Points Time Limit: 5000MS   Memory Limit: 30000K Total Submissions: 7327   Accepted: 2651 ...

随机推荐

  1. python 列出当前目录下的所有文件和目录名

    >>> import os # 导入os模块,模块的概念后面讲到 >>> [d for d in os.listdir('.')] # os.listdir可以列出 ...

  2. centos8 安装 docker

    centos 安装docker  官方参考地址:https://docs.docker.com/install/linux/docker-ce/centos/ 里面包含包下载地址: https://d ...

  3. 第十一节:Asp.Net Core 之内容缓存(IMemoryCache)

    1. 整体说明 ASP.NET Core 支持多种不同的缓存,最简单的缓存基于 IMemoryCache,它表示存储在 Web 服务器内存中的缓存,内存缓存可以存储任何对象,存储形式键值对,需要 .n ...

  4. AnyProxy代理

    背景:当一个公司测试团队有多个人的时候,只需搭建一个AnyProxy服务,其它小伙伴浏览器上打开AnyProxy页面,手机上设置代理就能抓到http.https请求了.解决了部分人电脑不正经的小伙伴f ...

  5. kafka Enabling Kerberos Authentication

    CDK 2.0 and higher Powered By Apache Kafka supports Kerberos authentication, but it is supported onl ...

  6. 7、VUE事件

    1.事件处理 Vue.js使用v-on指令监听DOM事件来触发JS回调函数. V-on: 缩写为 @ 事件回调函数可以传入$event这个事件对象. 2.事件修饰符 在事件处理程序中调用event.p ...

  7. APS.NET MVC + EF (02)---深入理解ADO.NET Entity Framework

    2.7 深入理解Entity Framework 性能问题几乎是一切ORM框架的通病,对于EF来说,引起性能低的原因主要在以下几个方面. 复杂的对象管理机制为了在.NET中更好地管理模型对象,EF提供 ...

  8. SQL Server中查找包含某个文本的存储过程 SQL 查找存储过程中出现过的文字怎么查询 查询整个数据库中出现的文本 sql 全局搜索

    --将text替换成你要查找的内容SELECT name, *FROM sysobjects o, syscomments sWHERE o.id = s.id AND text LIKE '%tex ...

  9. 简约而不简单的Django2.2 新手图文教程

     欢迎大家访问我的个人网站<刘江的博客和教程>www.liujiangblog.com  主要分享Python 及Django教程以及相关的博客! 版权所有,转载需注明来源! 2019年7 ...

  10. 1-python运算符和逻辑控制语句

    目录 运算符 条件语句if…else 断言assert 循环语句while 遍历for循环 1.运算符 1.1.算数运算符 加+.减-.乘*.除/.余%.次方**.向下取整除// 1.2.赋值运算符 ...