아직 만들고 있는 페이지입니다.

이 페이지는 아직 만드는 중입니다. 보이는 내용은 바뀔 수 있습니다.

Construct Point

시간 제한2초메모리 제한256 MB

요약
격자 삼각형 Q개에 대해 내부에 격자점이 있으면 그중 하나를 출력하고, 없으면 -1 -1을 출력한다.
난이도

보통10점 중 7점

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

문제

You have QQ triangles, numbered 11 through QQ.

The coordinates of the vertices of the ii-th triangle are (x_1_i,y_1_i)(x\_{1\_i}, y\_{1\_i}), (x_2_i,y_2_i)(x\_{2\_i}, y\_{2\_i}) and (x_3_i,y_3_i)(x\_{3\_i}, y\_{3\_i}) in counterclockwise order. Here, x_1_ix\_{1\_i}, x_2_ix\_{2\_i}, x_3_ix\_{3\_i}, y_1_iy\_{1\_i}, y_2_iy\_{2\_i} and y_3_iy\_{3\_i} are all integers.

For each triangle, determine if there exists a grid point contained in its interior (excluding the boundary). If it exists, construct one such point.

입력

Input is given in the following format:

QQ

x_1_1x\_{1\_1} y_1_1y\_{1\_1} x_2_1x\_{2\_1} y_2_1y\_{2\_1} x_3_1x\_{3\_1} y_3_1y\_{3\_1}

x_1_2x\_{1\_2} y_1_2y\_{1\_2} x_2_2x\_{2\_2} y_2_2y\_{2\_2} x_3_2x\_{3\_2} y_3_2y\_{3\_2}

…\ldots

x_1_Qx\_{1\_Q} y_1_Qy\_{1\_Q} x_2_Qx\_{2\_Q} y_2_Qy\_{2\_Q} x_3_Qx\_{3\_Q} y_3_Qy\_{3\_Q}

출력

Output should contain QQ lines.

In the ii-th line, if there is no grid point contained in the interior (excluding the boundary) of Triangle ii, print "-1 -1". If it exists, choose one such grid point, then print its xx-coordinate and yy-coordinate with a space in between.

제한

All input values are integers, 1≤Q≤10,0001 \leq Q \leq 10\\,000, 0≤x_1_i,x_2_i,x_3_i,y_1_i,y_2_i,y_3_i≤1090 \leq x\_{1\_i}, x\_{2\_i}, x\_{3\_i}, y\_{1\_i}, y\_{2\_i}, y\_{3\_i} \leq 10^9, (x_1_i,y_1_i)(x\_{1\_i}, y\_{1\_i}), (x_2_i,y_2_i)(x\_{2\_i}, y\_{2\_i}) and (x_3_i,y_3_i)(x\_{3\_i}, y\_{3\_i}) are listed in counterclockwise order, the triangles are non-degenerate.

예제1

  1. 예제 1

    입력
    4
    1 7 3 5 5 7
    1 4 1 2 5 4
    6 1 7 1 7 6
    11 3 11 4 8 5
    
    예상 출력
    3 6
    2 3
    -1 -1
    10 4