Triangle
Time limit1sMemory limit2048 MB
Pick one interior lattice point on each side of a lattice triangle and find the largest and smallest doubled area of the triangle they form, or -1.
- Level
Medium5 of 10
- Topics
- Number theory, Geometry, Math
- Solved
- No attempts yet
Problem
There is a triangle whose three vertices , , and all have integer coordinates. Select one point with integer coordinates on each side of the triangle, and connect the three points to form a new triangle. When creating the new triangle, no vertex of the given triangle can be selected as a vertex of the new triangle.
Depending on which points you select, the area of the new triangle may be large or small. Write a program that finds the largest and smallest areas of the new triangle, if they exist.
For example, as shown in the figure below, if the coordinates of the three vertices of the given triangle are , , and , the yellow triangle in Fig. L.1(a) has the largest area among the triangles that satisfy the condition, and the blue triangle in Fig. L.1(b) has the smallest area.

There may be no point with integer coordinates on any side of the given triangle, in which case the triangle you are looking for does not exist.
It is guaranteed that the three given points are not on a straight line.
Input
The input consists of a single line with six integers , , , , , and , which are the coordinates of vertices , , and , in that order. Each coordinate is an integer between and , inclusive.
Output
Let be the area of the new triangle with the largest area, and the area of the one with the smallest area. If such triangles exist, print and in that order, where both are positive integers. If no such triangle exists, print -1.