Imagine a plane (a dimension) and parallel lines in it. Normally they would never meet, but let us imagine that we are working in magical planes and all of them have a point where they bend infinitely in order to connect to the other planes. That point is called the critical breakpoint.
You are given a set of 4 integers separated by a single space, on every line of input, which represents plane coordinates for each line – {x1, y1}, {x2, y2}, the two points that form the line. When you get the command “Break it.”, you END the input. Your task is to find if the given lines form a plane which holds a critical breakpoint.
The critical breakpoint is formed only if the critical ratio of the current line is equal to the others’ critical ratio or is equal to ZERO. The critical ratio is, for each line, the absolute value of “(X2 + Y2) – (X1 + Y1)”.
If you find a non-zero critical ratio value it becomes the actual critical ratio, and if there is even one line, which’s critical ratio does not equal that value, and is not equal to zero, the current lines fail to create a critical breakpoint. Then you print “Critical breakpoint does not exist.”.
If a critical breakpoint is formed you need to calculate it. A critical breakpoint is equal to – the remainder of the division of, the critical ratio (which in this case is one for all the lines) powered by the count of lines, and the count of lines. If we have 4 lines and critical ratios – “10, 0, 0, 10” the breakpoint will be the remainder of: “(104) / 4”, which is 0.
Input:
-
The input will come in the form of lines on which you will get a set of 4 integers separated by a single space.
-
The input continues until you receive the command “Break it.”.
Output:
-
If a critical breakpoint has been found you need to print each of the lines in the following format:
-
“Line: [x1, y1, x2, y2]”
-
And after them, print the critical breakpoint in this format:
-
“Critical Breakpoint: {breakpoint}”
-
In case there is no breakpoint you must print only the following:
-
“Critical breakpoint does not exist.”
Constraints:
-
All of the input numbers will be valid integers in the range [-231 + 1, 231 - 1].
-
Allowed time/memory: 250ms/16MB.
Examples:
