#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 long double\tt long\ double.

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 44 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 9090^{\circ}, and its sides are a perfect 1:1:1:11:1:1:1

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 44 points on the 2D Cartesian coordinate system.

You need to use % magic magic to construct a square such that these 44 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 TT, the number of test cases.

For each test case, there are 44 lines. Each line contains two integers xi,yix_i, y_i, representing the coordinates of a point.

Output Format

For each test case, output 44 lines. Each line contains two real numbers, representing the coordinates of a vertex of the square. You must ensure that the ii-th given point lies on the side formed by the ii-th and the i mod 4+1i\ \text{mod}\ 4+1-th output vertices, and that the side containing the ii-th given point and the side containing the i mod 4+1i\ \text{mod}\ 4+1-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 SPJ\tt SPJ.

If the answer is not unique, output any one.

It will be accepted (AC\tt \green {AC}) as long as the difference between the lengths of the four sides is 102\le 10^{-2}, the angle between any two adjacent sides is within π2±102\frac{\pi}{2}\pm 10^{-2}, and letting the given point be (p,q)(p,q), there exists a point (p,q+k) (k1)(p,q+k)\ (|k|\leq 1) on the line of the corresponding side.

Constraints:

For 30%30\% of the testdata, T=1T=1, xi,yi103|x_i|, |y_i| \le 10^3.

For 70%70\% of the testdata, 1T5×1041 \le T \le 5\times 10^4, xi,yi106|x_i|, |y_i| \le 10^6.

For 100%100\% of the testdata, 1T5×1051 \le T \le 5\times 10^5, xi,yi109|x_i|, |y_i| \le 10^9.

The testdata guarantees that among the 66 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 88 digits after the decimal point.

Translated by ChatGPT 5