博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
hdu 1007 Quoit Design
阅读量:5967 次
发布时间:2019-06-19

本文共 2827 字,大约阅读时间需要 9 分钟。

Quoit Design

Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)

Total Submission(s): 49941    Accepted Submission(s): 13171

Problem Description
Have you ever played quoit in a playground? Quoit is a game in which flat rings are pitched at some toys, with all the toys encircled awarded.
In the field of Cyberground, the position of each toy is fixed, and the ring is carefully designed so it can only encircle one toy at a time. On the other hand, to make the game look more attractive, the ring is designed to have the largest radius. Given a configuration of the field, you are supposed to find the radius of such a ring.
Assume that all the toys are points on a plane. A point is encircled by the ring if the distance between the point and the center of the ring is strictly less than the radius of the ring. If two toys are placed at the same point, the radius of the ring is considered to be 0.
 

 

Input
The input consists of several test cases. For each case, the first line contains an integer N (2 <= N <= 100,000), the total number of toys in the field. Then N lines follow, each contains a pair of (x, y) which are the coordinates of a toy. The input is terminated by N = 0.
 

 

Output
For each test case, print in one line the radius of the ring required by the Cyberground manager, accurate up to 2 decimal places. 
 

 

Sample Input
2 0 0 1 1 2 1 1 1 1 3 -1.5 0 0 0 0 1.5 0
 

 

Sample Output
0.71 0.00 0.75
 

 

Author
CHEN, Yue
 

 

Source
 

 

Recommend
JGShining   |   We have carefully selected several similar problems for you:            
/*  最小点距离问题   采用分治算法,假设对于1-n的区间,我们已经求出1~m(m是中点)和m+1~n的结果分别是d1和d2,  那么如果1~n的答案出现在这两个单独的区间内,很明显就是min(d1,d2),否则在两个区间之间产生。  如果直接两重循环枚举两个区间的数会T,所以考虑优化:  ①:如果某个点到m的距离大于min(d1,d2),那么不考虑。  ②:首先用到一个结论:        假设有一个点q,坐标是xq, yq。可以证明在以q为底边中点,长为2d,宽为d的矩形区域内不会有超过6个点        (证明见算法导论,然而我并没看懂,Orz)      有了这个结论之后,我们将第一次优化后的点按照y排序,对于一个点i,如果某个点j与i的y坐标之差大于之前求出的ans,      那么j之后的就不用计算了。(不是很明白复杂度的证明) */#include
#include
#include
#define pf(x) ((x)*(x))using namespace std;const int N=1e5+10;struct node{ double x,y;}qx[N],qy[N];int n;bool cmpx(const node &a,const node &b){ return a.x
>1,cnt=0; double ans=min(solve(l,mid),solve(mid+1,r)); for(int i=l;i<=r;i++){ if(fabs(qx[i].x-qx[mid].x)<=ans){ qy[++cnt]=qx[i]; } } sort(qy+1,qy+cnt+1,cmpy); for(int i=1;i<=cnt;i++){ for(int j=i+1;j<=cnt;j++){ if(qy[j].y-qy[i].y>=ans) break; ans=min(ans,getdis(qy[i],qy[j])); } } return ans;}void work(){ for(int i=1;i<=n;i++) scanf("%lf%lf",&qx[i].x,&qx[i].y); sort(qx+1,qx+n+1,cmpx); printf("%.2lf\n",solve(1,n)/2);}int main(){ while(scanf("%d",&n)==1&&n) work(); return 0;}

 

转载于:https://www.cnblogs.com/shenben/p/6283249.html

你可能感兴趣的文章
大型网站系统架构的演化
查看>>
JQuery 如何选择带有多个class的元素
查看>>
The absolute uri: http://java.sun.com/jsp/jstl/core cannot be resolved in either web.xml or the jar
查看>>
VS快速生成JSON数据格式对应的实体
查看>>
Word2vec 模型载入(tensorflow)
查看>>
Linux内核——定时器和时间管理
查看>>
J2EE之初识JSP
查看>>
RabbitMq消息序列化简述
查看>>
别人要访问我的电脑上部署的tomcat,必须关闭防火墙吗?
查看>>
opencv2使用形态学滤波对图像进行边缘及角点检測
查看>>
Git协作流程(转)
查看>>
iOS UI-自动布局(Autoresizing)
查看>>
i.e., e.g., etc.
查看>>
计算机视觉与模式识别代码合集第二版three
查看>>
Android studio SweetAlert for Android
查看>>
sql中的CHARINDEX和暂时表
查看>>
火炬之光模型导出(Unity载入火炬之光的模型)
查看>>
git忽略文件【转】
查看>>
Web上的支持的图片格式以及它们之间的区别
查看>>
随意而为
查看>>