A Tale of Two Right Angled Triangles
All submissions for this problem are available.
You are given two right angled triangles. You are given their side lengths. The first triangle is ABC, where side AB is the hypotenuse. Length of AB is c, that of AC is b, and that of BC is a. Similarly, the second triangle is DEF, where DE is the hypotenuse. Length of DE is f, that of DF is e, and that of EF is d.
First we define minimum area enclosing axis-parallel rectangle of some figures. It will be a rectangle which is axis parallel (i.e. each of its sides should be parallel to x or y axis) that encloses all the figures and has the minimum possible area. By enclosing, we mean that all the figures should be inside the rectangle.
You have to find a set of coordinates to assign to the points A, B, C, D, E, F such that the minimum area enclosing axis-parallel rectangle of the two triangles has sides L and R, i.e. one side is of length L, and the other is of length R. Also, each of the sides AC, BC, DF, EF should be parallel to either x or y axis. If it is not possible to assign the coordinates, output -1.
- The first line of the input contains a single integer T denoting the number of test cases. The description of T test cases follows.
- The only line of each test case contains eight space separated integers denoting the lengths a, b, c, d, e, f, L, R.
For each test case, either output -1 if it is impossible to assign the coordinates. Otherwise, output six lines each containing two space separated integers corresponding to the coordinates of points A, B, C, D, E, F in that order. You can output any possible coordinates that have their absolute values less than or equal to 109.
- 1 ≤ T ≤ 105
- 1 ≤ a, b, c, d, e, f, L, R ≤ 108
- a2 + b2 = c2
- d2 + e2 = f2
Input 2 3 4 5 3 4 5 4 4 3 4 5 3 4 5 2 4 Output 2 5 5 1 2 1 2 4 6 1 6 4 -1
Testcase 1: The output corresponds to the image shown below:
Notice that all the 6 side lengths are maintained, and the sides AC, BC, DF, EF are all axis-parallel. The minimum area enclosing axis-parallel rectangle of these two triangles is shown in the next image:
Notice that this is a rectangle with side lengths 4 and 4, just as we wanted. Hence this is a valid output.
|Tags||admin2, easy, gwr17rol|
|Time Limit:||2 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.6, PYP3|
Fetching successful submissions
If you are still having problems, see a sample solution here.