eolymp
bolt
Try our new interface for solving problems
Problems

Lowest Pyramid

Lowest Pyramid

You are constructing a triangular pyramid with a sheet of craft paper with grid lines. Its base and sides are all of triangular shape. You draw the base triangle and the three sides connected to the base on the paper, cut along the outer six edges, fold the edges of the base, and assemble them up as a pyramid. You are given the coordinates of the base’s three vertices, and are to determine the coordinates of the other three. All the vertices must have integral \textbf{X}- and \textbf{Y}-coordinate values between \textbf{−100} and \textbf{+100} inclusive. Your goal is to minimize the height of the pyramid satisfying these conditions. \textit{\textbf{Figure 1}} shows some examples. \includegraphics{https://static.e-olymp.com/content/a9/a9c34abb14b04f9996aabebba07b404aed9c555c.jpg} \textit{\textbf{Figure 3}}: Some craft paper drawings and side views of the assembled pyramids \InputFile The input consists of multiple datasets, each in the following format. \textbf{X_0 Y_0 X_1 Y_1 X_2 Y_2} They are all integral numbers between \textbf{−100} and \textbf{+100} inclusive. (\textbf{X_0}, \textbf{Y_0}), (\textbf{X_1}, \textbf{Y_1}), (\textbf{X_2}, \textbf{Y_2}) are the coordinates of three vertices of the triangular base in counterclockwise order. The end of the input is indicated by a line containing six zeros separated by a single space. \OutputFile For each dataset, answer a single number in a separate line. If you can choose three vertices (\textbf{X_a}, \textbf{Y_a}), (\textbf{X_b}, \textbf{Y_b}) and (\textbf{X_c}, \textbf{Y_c}) whose coordinates are all integral values between \textbf{−100} and \textbf{+100} inclusive, and triangles (\textbf{X_0}, \textbf{Y_0})--(\textbf{X_1}, \textbf{Y_1})--(\textbf{X_a}, \textbf{Y_a}), (\textbf{X_1}, \textbf{Y_1})--(\textbf{X_2}, \textbf{Y_2})--(\textbf{X_b}, \textbf{Y_b}), (\textbf{X_2}, \textbf{Y_2})--(\textbf{X_0}, \textbf{Y_0})--(\textbf{X_c}, \textbf{Y_c}) and (\textbf{X_0}, \textbf{Y_0})--(\textbf{X_1}, \textbf{Y_1})--(\textbf{X_2}, \textbf{Y_2}) do not overlap each other (in the \textbf{XY}-plane), and can be assembled as a triangular pyramid of positive (non-zero) height, output the minimum height among such pyramids. Otherwise, output \textbf{−1}. You may assume that the height is, if positive (non-zero), not less than \textbf{0.00001}. The output should not contain an error greater than \textbf{0.00001}.
Time limit 30 seconds
Memory limit 64 MiB
Input example #1
0 0 1 0 0 1
0 0 5 0 2 5
-100 -100 100 -100 0 100
-72 -72 72 -72 0 72
0 0 0 0 0 0
Output example #1
2
1.49666
-1
8.52936
Source ACM ICPC Japan Regional 2007