Four Points

All submissions for this problem are available.
Read problems statements in Mandarin Chinese, Russian and Vietnamese as well.
You are given 4 points on the 2D plane. You should tell whether there is a triangle whose sides pass through all the 4 points, and if there is, then find one such triangle. The outputted triangle can be degenerate as well (that is, all three of its vertices can be collinear).
Input
 The first line of the input contains an integer T, denoting the number of test cases.
 Each testcase is described by a single line containing 8 spaceseparated integers, x_{1}, y_{1}, x_{2}, y_{2}, x_{3}, y_{3}, x_{4} and y_{4}. These describe the coordinates of the 4 given points, which are (x_{1}, y_{1}), (x_{2}, y_{2}), (x_{3}, y_{3}) and (x_{4}, y_{4}).
Output
For each testcase output its answer in a new line. If there is no triangle which perfectly pass through the 4 given points then output "NO". Otherwise output "YES", followed by 6 real numbers p_{1}, q_{1}, p_{2}, q_{2}, p_{3} and q_{3} in the same line. These should describe the vertices of the triangle: (p_{1}, q_{1}), (p_{2}, q_{2}) and (p_{3}, q_{3}). These points can be in any order, but they should satisfy (10^{6} ≤ p_{1}, q_{1}, p_{2}, q_{2}, p_{3}, q_{3} ≤ 10^{6}) . It is guaranteed that if the answer is "YES", there will be at least one triangle satisfying these constraints.
The triangle will be accepted if, for every input point A = (x_{i}, y_{i}), there exists an edge (say its endpoints are B = (p_{i}, q_{i}) and C = (p_{j}, q_{j})) of the triangle such that the absolute difference between dist(B, C) and dist(B, A) + dist(A, C) is less than 10^{9}.
Constraints
 1 ≤ T ≤ 10,000
 100 ≤ x_{1}, y_{1}, x_{2}, y_{2}, x_{3}, y_{3}, x_{4}, y_{4} ≤ 100
 No two points will coincide.
Example
Input: 2 1 1 1 3 1 2 2 1 1 1 2 2 2 0 1 0 Output: YES 1.000 1.000 1.000 4.000 3.000 1.000 YES 0.000 0.000 3.000 3.000 3.000 0.000
Explanation
The first testcase corresponds to this image:
The Ai's (marked in red) correspond to the input points, and the triangle is the outputted triangle.
The second testcase corresponds to this image:
Author:  kingofnumbers 
Tags  kingofnumbers 
Date Added:  1062017 
Time Limit:  1 sec 
Source Limit:  50000 Bytes 
Languages:  ADA, ASM, BASH, BF, C, C99 strict, CAML, CLOJ, CLPS, CPP 4.3.2, CPP 6.3, CPP14, CS2, D, ERL, FORT, FS, GO, HASK, ICK, ICON, JAVA, JS, LISP clisp, LISP sbcl, LUA, NEM, NICE, NODEJS, PAS fpc, PAS gpc, PERL, PERL6, PHP, PIKE, PRLG, PYPY, PYTH, PYTH 3.5, RUBY, SCALA, SCM chicken, SCM guile, SCM qobi, ST, TCL, TEXT, WSPC 
Comments
 Please login at the top to post a comment.
SUCCESSFUL SUBMISSIONS
Fetching successful submissions
HELP
If you are still having problems, see a sample solution here. 