How many squares?
Time limit1sMemory limit256 MB
Count quadruples of the given infinite lines that form the four sides of a square.
Problem
A quiz in a web advertisement asks how many squares a picture holds. To improve your odds of winning, you decide to write a program that counts the answer. To keep the task simple, assume the picture holds only infinite lines, not segments.
Count how many squares the lines in the picture form.
Four lines , , , form a square when all three conditions below hold.
- and are parallel.
- and are perpendicular to and , so and are parallel to each other.
- The distance between and equals the distance between and .
The order in which you pick the four lines does not matter, so a square made of the same four lines counts once.
Input
The first line contains the number of lines . ()
Each of the next lines describes one line with four integers , , , . That line passes through the points and . All four integers have absolute value at most .
The two points describing a line are different, and the lines are all different from each other.
Output
Print the number of squares formed by the given lines as a single integer on one line.