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

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

Quoit Design

Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 130 Accepted Submission(s): 72
 
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
20 01 121 11 13-1.5 00 00 1.50
 
Sample Output
0.710.000.75
 

 

题目要求求一个最近点对。

参考了一下别人的方法。

神分治 + 神剪支 + 神排序 就过了。

学习了一种新的排序方法 。 有所收获~~

 

 

#include 
#include
#include
#include
#include
using namespace std;const int N = 100010;const double INF = 1e10;struct node{ double x, y ; }e[N];int n ;inline bool cmpx(const node &a , const node &b ){ return a.x
> 1; double ans = min( solve( l , mid ) , solve( mid + 1 , r) ) ; int cnt = 0 ; for( int i = l ; i <= r ; ++i ){ if( e[i].x >= e[mid].x - ans && e[i].x <= e[mid].x + ans ){ a[cnt++] = i ; } } sort ( a , a + cnt , cmpy ); for( int i = 0 ; i < cnt ; ++ i ){ for( int j = i + 1 ; j < cnt ; ++j ){ if( e[ a[i] ].y + ans <= e[ a[j] ] .y )break ; ans = min( ans , dis( e[ a[i] ] ,e[ a[j] ] ) ); } } return ans ;}int main(){ ios::sync_with_stdio(false); while( cin >> n && n ){ for( int i = 0 ; i < n ; ++i ){ cin >> e[i].x >> e[i].y ; } sort( e, e + n , cmpx ); printf("%.2lf\n", ( solve( 0 ,n-1 ) / 2.0 ) ); }}

 

转载于:https://www.cnblogs.com/hlmark/p/3998952.html

你可能感兴趣的文章
Hibernate Validation与Spring整合各注解的用法Demo
查看>>
myeclipse debug 工具栏不见了
查看>>
程序员成熟的标志
查看>>
How Google Backs Up The Internet Along With Exabytes Of Other Data
查看>>
js----预解析,作用域链
查看>>
leetcode 264. Ugly Number II
查看>>
如何创建Hiren的BootCD USB磁盘 -- 制作U盘启动盘
查看>>
lubuntu自动登录(lxde)
查看>>
Python--day39--管道和数据共享(面试可能会问到)
查看>>
第十二章 Python网络编程
查看>>
Caffe错误汇总与解决办法
查看>>
1079. Total Sales of Supply Chain (25)
查看>>
xcrun: error: unable to find utility "PackageApplication", not a developer tool or in PATH
查看>>
Oracle数据库中的左连接与右连接
查看>>
POJ-1742 Coins
查看>>
segmentController
查看>>
淘宝初始化代码 - 解决浏览器的兼容问题
查看>>
在win8 64位操作系统下Power Designer 16.5对MySQL5.6逆向工程的配置详解
查看>>
07.Javascript——入门高阶函数
查看>>
LeetCode – Refresh – Remove Duplicates from Sorted Array
查看>>