HDU 1007 (division and Control Law)

Source: Internet
Author: User

It is implemented using the semi-segmentation method. after dividing a heap into two heaps and recursively obtaining the minimum distance between the two heaps, the key is to determine whether the distance between the two heaps is smaller, then we can use some optimizations to solve this problem.

Try again next timeAlgorithmThe method in the introduction should be more stable. I feel that this method is still very difficult, and there may be data grams, but it is also difficult to get this data.

We also feel that the division and control method is very similar to the Merge Sorting.

Quoit Design

Time Limit: 10000/5000 MS (Java/others) memory limit: 65536/32768 K (Java/Others)
Total submission (s): 15345 accepted submission (s): 3814

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 input20 01 121 11 13-1.5 00 00 1.50

 

Sample output0.710.000.75

 

Authorchen, Yue

 

Sourcezjcpc2004

 

Recommendjgshining
# Include <stdio. h> # Include <String . H> # Include <Math. h> # Include <Algorithm> # Include <Iostream> Using   Namespace  STD;  # Define N 100100 Struct  Node {  Double  X, Y;} G [N]; node save [N];  Int  CMP (node T, node T1 ){ Return T. x < T1.x ;}  Int  CMP1 (node T, node T1 ){  Return T. Y < T1.y ;}  Double  Cal (node T, node T1 ){  Return SQRT (T. x-t1.x) * (T. x-t1.x) + (T. y-t1.y) * (T. Y- T1.y ));}  Double FUC ( Int B, Int  D ){ If (D-B = 1 ) Return  Cal (G [B], G [d]);  If (D-B = 2  ){  Return Min (CAL (G [B], G [B + 1 ]), Min (CAL (G [B], G [d]), Cal (G [B + 1  ], G [d]);}  Int Mid = (B + d )/ 2  ; Double Mi = min (FUC (B, mid), FUC (Mid + 1  , D ));  For ( Int I = mid- 1 ; I> = B; I -- ){  If (G [Mid]. X-G [I]. x> Mi) {B = I;  Break  ;}}  For ( Int I = mid; I <= D; I ++ ){  If (G [I]. X-G [Mid- 1 ]. X> Mi) {d = I;  Break  ;}}  Int CNT = 0  ;  For ( Int I = B; I <= D; I ++ ) Save [CNT ++] =G [I]; sort (save, save + CNT, CMP1 );  For ( Int I = 0 ; I <CNT; I ++ )  For ( Int J = I + 1 ; J <CNT; j ++ ){  If (Save [J]. Y-save [I]. Y> mi) Break ; // This optimization is very important.              If (CAL (save [I], save [J]) <mi) MI = Cal (save [I], save [J]);}  Return  Mi ;}  Int  Main (){  Int  N;  While (Scanf ( "  % D  " , & N )&& N ){  For (Int I = 0 ; I <n; I ++ ) {Scanf (  "  % Lf  " , & G [I]. X ,& G [I]. Y);} Sort (G, G + N, CMP); printf (  "  %. 2lf \ n  " , FUC ( 0 , N- 1 )/ 2 );}  Return   0  ;} 

 

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.