No.55 An Easy Job: All You Have to Do Is Draw a Square
タグ : / 解いたユーザー数 315
作問者 :
nmnmnmnmnmnmnm
/ テスター :
Problem Statement
You were handed the integer coordinates of 4 distinct points.
Your job is to draw a square on graph paper with these 4 points as its vertices.
However, you have lost track of exactly one of the 4 points.
All you know are the coordinates of the remaining 3 points.
If a square can be drawn by guessing the missing point,
answer with the coordinates of that one point which makes the square possible.
If a square cannot be drawn, the answer is -1.
Input
\(X1\,Y1\,X2\,Y2\,X3\,Y3\)
The coordinates of the 3 points \((X1,Y1)、(X2,Y2)、(X3,Y3)\) are given, separated by single-byte spaces.
All coordinate values are given as integers. \(-100 \le X1,Y1,X2,Y2,X3,Y3 \le 100\).
The coordinates of the 3 points are all distinct, and it is not known which vertex of the square each of them corresponds to.
Output
X4 Y4
Output the remaining point (X4,Y4) that makes the square possible on one line in the format above.
Put a single-byte space between X4 and Y4.
If a square cannot be drawn, output only
-1
on one line.
In both cases, whether a square can be drawn or not, do not forget the newline at the end.
Sample
Sample 1
Input
0 0 1 0 0 1
Output
1 1
The 3 points (0,0), (1,0), (0,1) are known.
If the remaining point is (1,1), a square with side length 1 can be drawn.
Sample 2
Input
0 0 2 0 2 1
Output
-1
A rectangle can be drawn, but no matter how hard you try, a square cannot be drawn.
Therefore, the answer is -1.
Sample 3
Input
1 2 2 -1 -1 -2
Output
-2 1
The sides of the square do not have to be parallel to the x-axis or y-axis.
Sample 4
Input
8 10 14 14 13 9
Output
9 15
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。