链接

详解http://blog.sina.com.cn/s/blog_6e7b12310100qnex.html

 #include <iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<stdlib.h>
#include<vector>
#include<cmath>
#include<queue>
#include<set>
using namespace std;
#define N 100000
#define LL long long
#define INF 0xfffffff
const double eps = 1e-;
const double pi = acos(-1.0);
const double inf = ~0u>>;
set<int>st;
struct point
{
double x,y,r;
point(double x = ,double y = ):x(x),y(y){}
int id;
}p[N],rank[N];
struct line
{
double po;
int id;
}lef[N],rig[N];
int rk[N],n,pp[N];
double mid;
typedef point pointt;
point operator -(point a,point b)
{
return point(a.x-b.x,a.y-b.y);
}
int dcmp(double x)
{
if(fabs(x)<eps) return ;
return x<?-:;
}
double dis(point a)
{
return sqrt(a.x*a.x+a.y*a.y*1.0);
}
int is_cross(int a,int b)
{
double dd = dis(rank[a]-rank[b]);
if(dcmp(dd-rank[a].r-rank[b].r-mid-mid)>) return ;
return ;
}
int judge(int a)
{
set<int>::iterator it=st.insert(a).first;//插入a后所在位置
if(it!=st.begin())
{
if(is_cross(a,*--it))
return ;
it++;
}
if(++it!=st.end())
{
if(is_cross(a,*it)) return ;
}
return ;
}
int cal()
{
st.clear();
int i = ,j = ;
while(i<=n||j<=n)
{
if(j==n+||(i!=n+&&dcmp(lef[i].po-mid-(rig[j].po+mid))<=))//如果当且i圆的最左端小于j圆的最右端 将i插进来
{
int ip = rk[lef[i].id];
if(judge(ip))
return ;
i++;
}
else
{
st.erase(rk[rig[j].id]);
j++;
}
}
return ;
}
double solve()
{
double low = 0.0,high = dis(p[]-p[])-p[].r-p[].r;
while(low+eps<high)//二分距离
{
mid = (high+low)/;
if(cal())
high = mid;
else low = mid;
}
return high+low;
}
bool cmp(line a,line b)
{
return a.po<b.po;
}
bool cmpp(point a,point b)
{
if(a.y==b.y) return a.x<b.x;
return a.y<b.y;
}
int main()
{
int t,i;
cin>>t;
while(t--)
{
scanf("%d",&n);
for(i = ; i <=n ;i++)
{
scanf("%lf%lf%lf",&p[i].x,&p[i].y,&p[i].r);
lef[i].po = p[i].x-p[i].r;//每个圆的最左端
lef[i].id = i;
rig[i].po = p[i].x+p[i].r;//每个圆的最右端
rig[i].id = i;
rank[i] = p[i];//按y坐标排序
rank[i].id = i;
}
sort(lef+,lef+n+,cmp);
sort(rig+,rig+n+,cmp);
sort(rank+,rank+n+,cmpp);
for(i = ; i <= n; i++)
{
rk[rank[i].id] = i;//每个圆按y坐标排序后位于第几
}
double ans = solve();
printf("%.6f\n",ans);
}
return ;
}

hdu3124Arbiter(最小圆距离-扫描线)的更多相关文章

  1. @codeforces - 793G@ Oleg and chess

    目录 @description - translation@ @solution@ @part - 1@ @part - 2@ @part - 3@ @part - 4@ @accepted code ...

  2. CSS动效集锦,视觉魔法的碰撞与融合(三)

    本文讲述的原理和相关demo 扇形DIV的使用——实现雷达扫描图 DIV环形布局—实现loading圈 动画的向量合成—实现抛物线动画 无限滚动动画—实现跑马灯效果 perspective和trans ...

  3. OJ题解记录计划

    容错声明: ①题目选自https://acm.ecnu.edu.cn/,不再检查题目删改情况 ②所有代码仅代表个人AC提交,不保证解法无误 E0001  A+B Problem First AC: 2 ...

  4. BZOJ_3476_[Usaco2014 Mar]The Lazy Cow_扫描线+切比雪夫距离

    BZOJ_3476_[Usaco2014 Mar]The Lazy Cow_扫描线+切比雪夫距离 Description It's a hot summer day, and Bessie the c ...

  5. BZOJ-3228 棋盘控制 线段树+扫描线+鬼畜毒瘤

    3228: [Sdoi2008]棋盘控制 Time Limit: 10 Sec Memory Limit: 128 MB Submit: 23 Solved: 9 [Submit][Status][D ...

  6. BZOJ-3225 立方体覆盖 线段树+扫描线+乱搞

    看数据范围像是个暴力,而且理论复杂度似乎可行,然后被卡了两个点...然后来了个乱搞的线段树+扫描线.. 3225: [Sdoi2008]立方体覆盖 Time Limit: 2 Sec Memory L ...

  7. 线段树总结 (转载 里面有扫描线类 还有NotOnlySuccess线段树大神的地址)

    转载自:http://blog.csdn.net/shiqi_614/article/details/8228102 之前做了些线段树相关的题目,开学一段时间后,想着把它整理下,完成了大牛NotOnl ...

  8. 最小圆覆盖 hdu 3007

    今天学习了一下最小圆覆盖, 看了一下午都没看懂, 晚上慢慢的摸索这代码,接合着别人的讲解, 画着图跟着代码一步一步的走着,竟然有些理解了. 最小圆覆盖: 给定n个点, 求出半径最小的圆可以把这些点全部 ...

  9. 【转换模型+扫描线】【UVA1398】Meteor

    The famous Korean internet company nhn has provided an internet-based photo service which allows The ...

随机推荐

  1. 使用percona xtradb cluster的IST方式添加新节点

    使用percona xtradb cluster的IST(Incremental State Transfer)特性添加新节点,防止新节点加入时使用SST(State SnapShop Transfe ...

  2. Python time clock()方法

    描述 Python time clock() 函数以浮点数计算的秒数返回当前的CPU时间.用来衡量不同程序的耗时,比time.time()更有用. 这个需要注意,在不同的系统上含义不同.在UNIX系统 ...

  3. C语言的数组名和对数组名取地址

    http://blog.csdn.net/zdcsky123/article/details/6517811 相信不少的C语言初学者都知道,数组名相当于指针,指向数组的首地址,而函数名相当于函数指针, ...

  4. Paths on a Grid(简单组合数学)

    Paths on a Grid Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 23008 Accepted: 5683 Desc ...

  5. win10 + VS2015 + EF6 + MySQL

    前置配置 在下面的网址去安装最新版的 (Connector/Net http://dev.mysql.com/downloads/connector/net/#downloads) 然后安装 MySQ ...

  6. iosanimationWithKeyPath

    animationWithKeyPath的值: transform.scale = 比例轉換     transform.scale.x = 闊的比例轉換     transform.scale.y ...

  7. android 入门 001 (界面布局)

    学android 首先学会怎么布局界面,我开始是学.net的,因工作需要学习一下安卓,外行写的不好,请多多见谅指教 .这一篇文章然我们来学习一下四种布局吧! RelativeLayout(相对布局) ...

  8. web打印

    实现方法 引用jquery和,jqprint到您的页面 <script language="javascript" src="jquery-1.4.4.min.js ...

  9. Xcode关闭ARC

    开启了ARC则不能显示调用dealloc/retain/release等手动内存管理操作,所以很多情况下需要关闭. Xcode中有两种途径可以关闭ARC. 1.创建项目时将ARC选项的勾取消掉. 2. ...

  10. Android 4.4之后删除短信进行处理

    android 4.4删除短信 android 4.4之后非默认的短信应用已经没有办法删除短信了.像以前那样用如下方法是不会没法删除短信的(即使在xml中配置了短信的读写权限),同时也不会有报错或其他 ...