链接

详解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. nodepad + 插件

    Notepad++是一款Windows环 境下免费开源的代码编辑器,支持的语言: C, C++ , Java , C#, XML,SQL,Ada, HTML, PHP, ASP, AutoIt, 汇编 ...

  2. Prince2七大原则(3)

    Prince2七大原则(3) 我们先来回顾一下,PRINCE2七大原则分别是持续的业务验证,经验学习,角色与责任,按阶段管理,例外管理,关注产品,剪裁. 第三个原则:明确定义的角色和职责. 项目离不开 ...

  3. 1029 C语言文法定义与C程序的推导过程

    1 阅读并理解提供给大家的C语言文法文件. 2 参考该文件写出一个自己好理解版的现实版的完整版的C语言文法. 3 给出一段C程序,写出用上述文法产生这段C程序的推导过程. program → exte ...

  4. SDUT 2416:Fruit Ninja II

    Fruit Ninja II Time Limit: 5000MS Memory limit: 65536K 题目描述 Have you ever played a popular game name ...

  5. asp.net c# 打开新页面或页面跳转

    1.最常用的页面跳转(原窗口被替代):Response.Redirect("XXX.aspx"); 2.利用url地址打开本地网页或互联网:Respose.Write(" ...

  6. 20150618_Andriod _KSOAP2_多线程

    参考地址:http://blog.csdn.net/long704480904/article/details/8636734 webService:基于SOAP协议的远程调用标准,通过webServ ...

  7. 让VS自动生成我们自己的注释

    1. 找到你VS的安装目录:C:\Program Files (x86)\Microsoft Visual Studio 11.0 2. 在VS安装路径下依次找到这些文件夹:\Common7\IDE\ ...

  8. 如何用Pr完成作业~

    要求~ 我的工具~(随便搞搞就好了,自己的录音还没弄~)

  9. Intel Code Challenge Final Round (Div. 1 + Div. 2, Combined) A

    Description You are given names of two days of the week. Please, determine whether it is possible th ...

  10. Python安装指南

    说明:我的安装环境是centos6.4 ,32位系统:(#号之后内容为注释说明内容) 1.准备 centos是自带python的,所以可以在shell下直接执行:python 可以看到相应的打印信息, ...