Symmetry
InterviewTime limit1sMemory limit128 MB
Given N distinct points in the plane, count how many lines reflect the whole set onto itself.
- Level
Medium6 of 10
- Topics
- Geometry, Hash map, Sorting, Implementation
- Solved
- No attempts yet
Problem
Farmer John has plotted the locations of his cows () on the 2D plane, each cow occupying a distinct point. He wonders how many distinct lines of symmetry this set of points has.
A line of symmetry is a line such that reflecting every point across it yields exactly the same set of points; in other words, the points on the two sides of the line are mirror images of each other.
Count the number of lines of symmetry of the point set.
Input
- Line : the single integer .
- Lines : line contains two space-separated integers, the and coordinates of the -th cow ().
Output
- Line : the number of distinct lines of symmetry of the point set.
Notes
For example, four points forming the corners of a square have lines of symmetry: one vertical, one horizontal, and two diagonal.