Pro.ID10147 TitleCow Tours Title链接http://10.20.2.8/oj/exercise/problem?problem_id=10147 AC36 Submit144 Ratio25.00% 时间&空间限制描述Farmer John has a number of pastures on his farm. Cow paths connect some pastures with certain other pastures, forming a field. But, at the present time, you can find at least two pastures that cannot be connected by any sequence of cow paths, thus partitioning Farmer John's farm into multiple fields. Farmer John would like add a single a cow path between one pair of pastures using the constraints below. A field's 'diameter' is defined to be the largest distance of all the shortest walks between any pair of pastures in the field. Consider the field below with five pastures, located at the points shown, and cow paths marked by lines: 15,15 20,15 The 'diameter' of this field is approximately 12.07106, since the longest of the set of shortest paths between pairs of pastures is the path from A to E (which includes the point set {A,B,E}). No other pair of pastures in this field is farther apart when connected by an optimal sequence of cow paths. Suppose another field on the same plane is connected by cow paths as follows: *F 30,15 In the scenario of just two fields on his farm, Farmer John would add a cow path between a point in each of these two fields (namely point sets {A,B,C,D,E} and {F,G,H}) so that the joined set of pastures {A,B,C,D,E,F,G,H} has the smallest possible diameter. Note that cow paths do not connect just because they cross each other; they only connect at listed points. The input contains the pastures, their locations, and a symmetric "adjacency" matrix that tells whether pastures are connected by cow paths. Pastures are not considered to be connected to themselves. Here's one annotated adjacency list for the pasture {A,B,C,D,E,F,G,H} as shown above: A B C D E F G H Other equivalent adjacency lists might permute the rows and columns by using some order other than alphabetical to show the point connections. The input data contains no names for the points. The input will contain at least two pastures that are not connected by any sequence of cow paths. Find a way to connect exactly two pastures in the input with a cow path so that the new combined field has the smallest possible diameter of any possible pair of connected pastures. Output that smallest possible diameter. 输入Line 1: An integer, N (1 ≤ N ≤ 150), the number of pastures Line 2 - N+1: Two integers, X and Y (0 ≤ X ,Y ≤ 100000), that denote that X, Y grid location of the pastures; all input pastures are unique. 输出Description Farmer John has a number of pastures on his farm. Cow paths connect some pastures with certain other pastures, forming a field. But, at the present time, you can find at least two pastures that cannot be connected by any sequence of cow paths, thus partitioning Farmer John's farm into multiple fields. Farmer John would like add a single a cow path between one pair of pastures using the constraints below. A field's 'diameter' is defined to be the largest distance of all the shortest walks between any pair of pastures in the field. Consider the field below with five pastures, located at the points shown, and cow paths marked by lines: 15,15 20,15 The 'diameter' of this field is approximately 12.07106, since the longest of the set of shortest paths between pairs of pastures is the path from A to E (which includes the point set {A,B,E}). No other pair of pastures in this field is farther apart when connected by an optimal sequence of cow paths. Suppose another field on the same plane is connected by cow paths as follows: *F 30,15 In the scenario of just two fields on his farm, Farmer John would add a cow path between a point in each of these two fields (namely point sets {A,B,C,D,E} and {F,G,H}) so that the joined set of pastures {A,B,C,D,E,F,G,H} has the smallest possible diameter. Note that cow paths do not connect just because they cross each other; they only connect at listed points. The input contains the pastures, their locations, and a symmetric "adjacency" matrix that tells whether pastures are connected by cow paths. Pastures are not considered to be connected to themselves. Here's one annotated adjacency list for the pasture {A,B,C,D,E,F,G,H} as shown above: A B C D E F G H Other equivalent adjacency lists might permute the rows and columns by using some order other than alphabetical to show the point connections. The input data contains no names for the points. The input will contain at least two pastures that are not connected by any sequence of cow paths. Find a way to connect exactly two pastures in the input with a cow path so that the new combined field has the smallest possible diameter of any possible pair of connected pastures. Output that smallest possible diameter. Input Line 1: An integer, N (1 ≤ N ≤ 150), the number of pastures Line 2 - N+1: Two integers, X and Y (0 ≤ X ,Y ≤ 100000), that denote that X, Y grid location of the pastures; all input pastures are unique. Output The output consists of a single line with the diameter of the newly joined pastures. Print the answer to exactly six decimal places. Do not perform any special rounding on your output. Sample Input 8 Sample Output 22.071068 Source 样例输入8 样例输出22.071068 作者 |