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

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

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

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

Solution

裸的平面最近点对,但要注意题目要求的是最大套圈的半径(radius),而所求出的最近点对间的距离相当于最大套圈的直径(diameter)。

Implementation

#include 
#define X first#define Y second#define INF 1e9#define N 1<<17using namespace std;typedef pair
P;P a[N];bool compare_y(const P &a, const P &b){ return a.Y
>1; double x=a[m].X, d=min(closest_pair(a, m), closest_pair(a+m, n-m)); inplace_merge(a, a+m, a+n, compare_y); vector

b; for(int i=0; i

=d) continue; for(auto p=b.rbegin(); p!=b.rend(); p++){ double dx=a[i].X-p->X, dy=a[i].Y-p->Y; if(dy>=d) break; d=min(d, sqrt(dx*dx+dy*dy)); } b.push_back(a[i]); } return d;}int main(){ for(int n; cin>>n, n; ){ for(int i=0; i

 

转载于:https://www.cnblogs.com/Patt/p/5710478.html

你可能感兴趣的文章
Solaris11修改主机名
查看>>
latex for wordpress(一)
查看>>
如何在maven工程中加载oracle驱动
查看>>
Flask 系列之 SQLAlchemy
查看>>
aboutMe
查看>>
【Debug】IAR在线调试时报错,Warning: Stack pointer is setup to incorrect alignmentStack,芯片使用STM32F103ZET6...
查看>>
一句话说清分布式锁,进程锁,线程锁
查看>>
FastDFS使用
查看>>
服务器解析请求的基本原理
查看>>
[HDU3683 Gomoku]
查看>>
下一代操作系统与软件
查看>>
【iOS越狱开发】如何将应用打包成.ipa文件
查看>>
[NOIP2013提高组] CODEVS 3287 火车运输(MST+LCA)
查看>>
Yii2 Lesson - 03 Forms in Yii
查看>>
Python IO模型
查看>>
DataGridView的行的字体颜色变化
查看>>
Java再学习——关于ConcurrentHashMap
查看>>
如何处理Win10电脑黑屏后出现代码0xc0000225的错误?
查看>>
局域网内手机访问电脑网站注意几点
查看>>
[Serializable]的应用--注册码的生成,加密和验证
查看>>