Under construction

Still being built. Things may change

Hermes' Colony

Time limit1sMemory limit128 MB

Summary
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 ax+by+cz=dax + by + cz = d. There are NN provinces in the colony. A city in a province is described by a point (x,y,z)(x, y, z) in three dimensions, and all coordinates xx, yy, and zz are between −100.00-100.00 and +100.00+100.00.

The first line contains the four real numbers aa, bb, cc, and dd. The second line contains the number of provinces NN. The remaining input describes the provinces one by one.

The description of a province begins with a line containing the number of cities MM (3≤M≤43 \le M \le 4) in that province, followed by MM lines. Each of these lines contains the xx, yy, and zz coordinates of one city in the province.

Output

For each province, print one line in the following format:

Province # p : L

Here pp is the serial number of the province in the order it appears in the input (1≤p≤N1 \le p \le N), and LL is the minimum length of the road network for that province. LL must be printed exact to two digits after the decimal point.

Examples3

  1. Example 1

    Input
    -0.126826 -0.780330 0.612372 3.000000
    2
    3
    11.593475 -0.702393 6.405027
    -43.361881 -34.677124 -48.269711
    -0.380480 -2.340990 1.837117
    4
    -15.033179 6.549108 10.130860
    -13.950171 -53.592907 -66.282234
    49.017246 0.979824 16.299353
    46.824024 12.971205 31.125420
    
    Expected output
    Province # 1 : 86.43
    Province # 2 : 175.15
    
  2. Example 2

    Input
    0 0 1 0
    1
    3
    0.000000 0.000000 0.000000
    20.000000 0.000000 0.000000
    6.000000 17.000000 0.000000
    
    Expected output
    Province # 1 : 34.55
    
  3. Example 3

    Input
    0 0 1 0
    1
    4
    0.000000 0.000000 0.000000
    20.000000 0.000000 0.000000
    20.000000 20.000000 0.000000
    0.000000 20.000000 0.000000
    
    Expected output
    Province # 1 : 54.64