#P8309. 〈 TREEのOI 2022 Spring 〉Dimension-2 Square
〈 TREEのOI 2022 Spring 〉Dimension-2 Square
Background
This problem may be slightly precision-sensitive. It is recommended to use .
On the night of the Lantern Festival, under the sky.
A group of people looked at a tree, a tree floating in the sky, hoping it would become a cycle.
This tree has nodes.
“It became a cycle!” someone shouted.
I immediately looked up into the sky…
What a standard square! No matter which astronomer comes to measure it, its angles are standard , and its sides are a perfect …
We saw that tree—no, that elegant and perfect cycle—slowly flying by, fitting exactly into the center of the bright full moon…

Problem Description
You are given the coordinates of points on the 2D Cartesian coordinate system.
You need to use % magic magic to construct a square such that these points lie on the lines containing the four sides of the square, respectively.
Input Format
This problem uses multiple test cases.
The first line contains an integer , the number of test cases.
For each test case, there are lines. Each line contains two integers , representing the coordinates of a point.
Output Format
For each test case, output lines. Each line contains two real numbers, representing the coordinates of a vertex of the square. You must ensure that the -th given point lies on the side formed by the -th and the -th output vertices, and that the side containing the -th given point and the side containing the -th given point are adjacent sides.
1
235 423
544 345
563 645
453 435
380.43769007 531.90429895
395.56394564 543.23089701
406.89054360 528.10464158
391.76428803 516.77804352
Hint
This problem uses .
If the answer is not unique, output any one.
It will be accepted () as long as the difference between the lengths of the four sides is , the angle between any two adjacent sides is within , and letting the given point be , there exists a point on the line of the corresponding side.
Constraints:
For of the testdata, , .
For of the testdata, , .
For of the testdata, , .
The testdata guarantees that among the lines formed by connecting any two points, no two lines are perpendicular to each other, and there is no line parallel to the coordinate axes. No three points are collinear. It is guaranteed that no solution has a side parallel to an axis. It is guaranteed that a solution exists.
For output precision, you need to keep at least digits after the decimal point.
Translated by ChatGPT 5