Triangle

시간 제한1초메모리 제한2048 MB

요약
세 꼭짓점의 좌표가 정수인 삼각형에서 각 변마다 꼭짓점이 아닌 정수 좌표 점을 하나씩 골라 만들 수 있는 새 삼각형 넓이의 최댓값과 최솟값을 구한다.
난이도

보통10점 중 7점

유형
수학, 정수론, 기하, 그리디
정답자
아직 제출이 없습니다

문제

There is a triangle whose coordinates of three vertices AA, BB, and CC are all integers. If you select a point on each side of the triangle whose coordinates are integers and connect those points, a new triangle is created. When creating a new triangle, no vertex of the given triangle can be selected as a vertex of the new triangle.

Depending on which points you select and connect, the area of the newly created triangle may be large or small.

You are to write a program that finds out the largest and smallest areas of the newly created triangle if they exist.

For example, as shown in the figure below, if the coordinates of the three vertices of the given triangle are (4,8)(4, 8), (−8,−1)(-8, -1), and (7,−7)(7, -7), the yellow triangle shown in Fig. L.1(a) has the largest area among those that satisfy the condition, and the blue triangle shown in Fig. L.1(b) has the smallest area.

There may not be a point on any side of the given triangle whose coordinates are integers, in which case the triangle you are looking for does not exist.

It is guaranteed that the three points of the given input are not on a straight line.

입력

Your program is to read from standard input. The input consists of a line containing six integers that are the (x,y)(x, y)-coordinates of the three vertices A=(A_x,A_y)A = \left(A\_x, A\_y\right), B=(B_x,B_y)B = \left(B\_x, B\_y\right), and C=(C_x,C_y)C = \left(C\_x, C\_y\right) of a triangle, which A_xA\_x, A_yA\_y, B_xB\_x, B_yB\_y, C_xC\_x, and C_yC\_y are given in that order. Each value of the coordinates is an integer between −109-10^9 and 10910^9, inclusive.

출력

Your program is to write to standard output. Let the area of the newly created triangle with the largest area be S_max⁡S\_\max, and the area of the triangle with the smallest area be S_min⁡S\_\min. If such triangles can be found, print 2S_max⁡2S\_\max and 2S_min⁡2S\_\min in that order, where both 2S_max⁡2S\_\max and 2S_min⁡2S\_\min are positive integers. If such triangles cannot be found, print -1.

예제3

  1. 예제 1

    입력
    4 8 -8 -1 7 -7
    
    예상 출력
    69 46
    
  2. 예제 2

    입력
    -8 1 7 11 7 -5
    
    예상 출력
    121 23
    
  3. 예제 3

    입력
    0 0 1 10 10 0
    
    예상 출력
    -1