8988: link doesn't want to cut tree

内存限制:128 MB 时间限制:1 S
题面:传统 评测方式:Special Judge 上传者:
提交:0 通过:0

题目描述


link has a convex quadrilateral farm, and he planted four trees at the four vertices of the farm to mark it.

Now link wants to expand his farm, and he has some requirements for the new farm:
  • The new farm should be a diamond shape, which is a quadrilateral with equal sides.
  • The new farm area should be twice that of the original farm.
  • link doesn't want to cut trees, so the four trees should be placed on each side of the new farm.

Formally, given a convex quadrilateral ABCDABCDABCD, you should calculate four distinct points A′B′C′D′A'B'C'D'ABCD, which satisfies:
  •  A′B′C′D′A'B'C'D'ABCD is a diamond shape, that is, ∣A′B′∣=∣B′C′∣=∣C′D′∣=∣D′A′∣|A'B'|=|B'C'|=|C'D'|=|D'A'|AB=BC=CD=DA.
  •  SA′B′C′D′=2SABCDS_{A'B'C'D'}=2S_{ABCD}SABCD=2SABCD.
  •  Point AAA is located on segment A′B′A'B'AB. Point BBB is located on segment B′C′B'C'BC. Point CCC is located on segment C′D′C'D'CD. Point DDD is located on segment D′A′D'A'DA.

You need to calculate A′B′C′D′A'B'C'D'ABCD or indicate that this is impossible.

输入格式


Each test contains multiple test cases. The first line of input contains a single integer t(1≤t≤104)t(1\leq t\leq 10^4)t(1t104) --- the number of test cases.
Each test case contains 888 integers xA,yA,xB,yB,xC,yC,xD,yDx_A,y_A,x_B,y_B,x_C,y_C,x_D,y_DxA,yA,xB,yB,xC,yC,xD,yD --- the coordinates of points A,B,C,DA,B,C,DA,B,C,D. The absolute value of all integers should not exceed 10410^4104.

输出格式


For each test case, if there is at least a solution, print "link doesn't cut tree!", then print 8 numbers, representing xA′,yA′,xB′,yB′,xC′,yC′,xD′,yD′x_{A'},y_{A'},x_{B'},y_{B'},x_{C'},y_{C'},x_{D'},y_{D'}xA,yA,xB,yB,xC,yC,xD,yD respectively.
If there is no possible solution, print "link cut tree!".
The answer would be considered correct if the absolute error of all conditions is no more than 10−510^{-5}105.

输入样例 复制

3
-2 1 2 1 2 -1 -2 -1
8 -2 -6 -4 -7 1 -2 4
-4 4 4 4 8 -2 -6 -3

输出样例 复制

Link doesn't cut tree!
-4 0 0 2 4 0 0 -2
Link cut tree!
Link doesn't cut tree!
-12 0 0 6 12 0 0 -6

数据范围与提示

Case 1:
Case 2:
Case 3:

分类标签