ACM-Quoit Design -- hdu1007 zoj2107

Source: Internet
Author: User

Quoit DesignTime Limit: 10000/5000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission (s): 28539 Accepted Submission (s): 7469

Problem DescriptionHave 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.
InputThe 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.
OutputFor 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
AuthorCHEN, Yue title: hdu 1007, zoj 2107

Type: find the nearest point. The method for finding the closest point of a plane is divide and conquer. Divide the vertex into two intervals, for example S1 and S2, and then calculate the point d1 of the closest vertex in S1, respectively, d2 of the closest vertex in S2 is used to calculate the closest vertex d = min (d1, d2) in S1 and S2. However, it cannot be forgotten that the closest vertex may be a point in S1 and a point in S2. Next is the essence of comparison: the position of the requested vertex must be between mid-d and mid + d. Then, start to find the vertex in this interval, and constantly update the d value. Finally, we can get d.
This question requires the final radius, so it must be divided by 2.
/*************************************** ************************************ Author: tree ** From: http://blog.csdn.net/lttree ** Title: Quoit Design ** Source: hdu 1007 zoj 2107 ** Hint: computational Ry-closest point *********************************** **************************************** * **/# include
 
  
# Include
  
   
# Include using namespace std; # define N 100001 struct Point {double x, y;} p [N]; int arr [N]; double Min (double a, double B) {return
   
    
> 1; double ans = Min (close_pair (l, mid), close_pair (mid + 1, r); int I, j, cnt = 0; // If the abscissa of the current p [I] Point is within the range (midpoint abscissa-ans, midpoint abscissa + ans), the serial number of the Record Point for (I = l; I <= r; ++ I) if (p [I]. x> = p [mid]. x-ans & p [I]. x <= p [mid]. x + ans) arr [cnt ++] = I; // sort the arr array interior point (arr, arr + cnt, cmp_y) according to the vertical coordinate from small to large ); for (I = 0; I
    
     
= Ans) break; ans = Min (ans, dis (p [arr [I], p [arr [j]);} return ans;} int main () {int I, n; while (scanf ("% d", & n )! = EOF & n) {for (I = 0; I
     
      


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.