Hermes' Colony
Time limit1sMemory limit128 MB
For each province of 3 or 4 planar points, compute the length of the minimum Steiner tree connecting the cities, allowing extra junction points.
- Level
Medium5 of 10
- Topics
- Geometry, Math, Brute force, Implementation
- Solved
- No attempts yet
Problem
Hermes, the Greek god of speed, has built a two-dimensional colony named Massilia in space. The colony consists of one or more provinces and lies on a single plane in three-dimensional space (a linear equation). Each province contains 3 or 4 cities, and all of these cities lie on their convex hull.
The citizens of each province want to build a road network that connects the cities of their own province. The construction material cannot be found in the colony and must be shipped from Earth, and the amount of material needed is proportional to the total length of the roads. The citizens therefore want to build the road network of shortest possible total length that connects the different cities of a province. To make the network shorter, they may also create new junctions at points that are not cities.
For each province, find the minimum total length of a road network that connects all of its cities.
Input
The colony is described by the plane . There are provinces in the colony. A city in a province is described by a point in three dimensions, and all coordinates , , and are between and .
The first line contains the four real numbers , , , and . The second line contains the number of provinces . The remaining input describes the provinces one by one.
The description of a province begins with a line containing the number of cities () in that province, followed by lines. Each of these lines contains the , , and coordinates of one city in the province.
Output
For each province, print one line in the following format:
Province # p : L
Here is the serial number of the province in the order it appears in the input (), and is the minimum length of the road network for that province. must be printed exact to two digits after the decimal point.