問題一覧 > 通常問題

No.55 An Easy Job: All You Have to Do Is Draw a Square

レベル : / 実行時間制限 : 1ケース 5.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 315
作問者 : nmnmnmnmnmnmnm / テスター : yuki2006
お気に入りにしたユーザー ProblemId : 83 / 自分の提出
問題文最終更新日: 2026-06-25 02:16:56
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 46 (順位表) の他の問題:

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もしくは右上の雲マークをクリックしてアカウントを作成してください。