链接

详解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. 关于PHP的正则表达式

    1.入门简介 简单的说,正则表达式是一种可以用于模式匹配和替换的强有力的工具.我们可以在几乎所有的基于UNIX系统的工具中找到正则表达式的身影,例如,vi编辑器,Perl或PHP脚本语言,以及awk或 ...

  2. 使用phpmyadmin导入SQL数据报错:#1062 - Duplicate entry '...

    使用phpmyadmin导入SQL数据报错: MySQL 返回: #1062 - Duplicate entry '0' for key 'PRIMARY' 出现此错误的原因是数据的主键重复了,错误信 ...

  3. HDU 3966:Aragorn's Story(树链剖分)

    http://acm.hdu.edu.cn/showproblem.php?pid=3966 题意:有n个点n-1条边,每个点有一个权值,有两种操作:询问一个点上权值是多少和修改u到v这条链上的权值. ...

  4. [BIM]STEP标准和EXPRESS语言

    参考:http://blog.sina.com.cn/s/blog_620be62e0100iqyb.html (BIM名词和术语(四)- IFC/STEP/EXPRESS) IFC标准使用形式化的数 ...

  5. [团队项目]SCRUM项目5.0

    5.0--------------------------------------------------- 1.团队成员完成自己认领的任务. 2.燃尽图:理解.设计并画出本次Sprint的燃尽图的理 ...

  6. c# web 缓存管理

    using System; using System.Collections; using System.Text.RegularExpressions; using System.Web; usin ...

  7. SQL-表链接

    查询两张表中相匹配的数据显示,不匹配的忽略 1.简单表连接 select * from 表1,表2 where 表1.字段=表2.字段 2.内链接 select * from 表1 inner joi ...

  8. LightOJ1002 分类: 比赛 最短路 2015-08-08 15:57 15人阅读 评论(0) 收藏

    I am going to my home. There are many cities and many bi-directional roads between them. The cities ...

  9. lua注释

    1. 单行注释 --  功能等同于C++中的// 2. 多行注释  --[[  注释的内容  ]]   功能等同于C++中的 /**/ 3. 多行注释   --[====[   注释和内容  ]=== ...

  10. 2016年12月9日 星期五 --出埃及记 Exodus 21:4

    2016年12月9日 星期五 --出埃及记 Exodus 21:4 If his master gives him a wife and she bears him sons or daughters ...