This page is still under construction.

Parts of this page are still being built. What you see may change.

Celtic Symmetry

Interview

Time limit2sMemory limit512 MB

Summary
Given up to 1000 distinct integer points in the plane, count the distinct lines of symmetry of the set.
Level

Medium7 of 10

Topics
Geometry, Hash map, Sorting, Math
Solved
No attempts yet

Problem

After a class on ancient Irish history, Diarmuid took an interest in geometric patterns hidden in the locations of neolithic tombs around Ireland. He plots the positions of NN tombs on the plane, and no two tombs sit at the same point. Count the lines of symmetry of this set of points.

A line of symmetry is a line such that the points on one side are mirror images of the points on the other side. In other words, reflecting every point of the set across the line must give back exactly the same set.

Input

The first line contains the number of tombs NN (2≤N≤10002 \le N \le 1000).

Each of the next NN lines contains two integers xx and yy, the coordinates of one tomb, separated by a space (−10000≤x,y≤10000-10000 \le x, y \le 10000). No coordinate pair is given twice.

Output

Print the number of distinct lines of symmetry of the point set.

Examples2

  1. Example 1

    Input
    3
    0 0
    0 1
    0 3
    
    Expected output
    1
    
  2. Example 2

    Input
    4
    0 0
    0 1
    1 0
    1 1
    
    Expected output
    4