408175: GYM103037 F Ice-T

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

F. Ice-Ttime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output

Ice-T has remained a powerful player in the rap game for almost forty years, ever since his debut in the early 80's. It is a little known secret that Ice-T powers his incredible rapping abilities by amassing points in a 2D plane and harvesting all of the 'T's that he can find among them.

A 'T' is defined to be a set of four points $$$A$$$, $$$B$$$, $$$C$$$, and $$$D$$$ where:

  1. Points $$$A$$$ and $$$B$$$ are collinear and form a segment $$$\overline{AB}$$$ that is parallel to either the $$$x$$$ or $$$y$$$ axis
  2. Point $$$C$$$ rests on the midpoint exactly equidistant between $$$A$$$ and $$$B$$$
  3. point $$$D$$$ forms a line segment perpendicular to the $$$\overline{AB}$$$ segment when connected with $$$C$$$

Help Ice-T become even more powerful! Given a set of $$$N$$$ points in 2D space, find the number of 'T's present.

Input

The first line of input contains a single integer $$$N$$$ ($$$1 \leq N \leq 1000$$$), the number of points in the 2D plane that Ice-T has already amassed. $$$N$$$ lines follow, each containing two space-separated integers $$$x_i$$$ and $$$y_i$$$ ($$$0 \leq x_i, y_i \leq 10^9$$$) which give the coordinate location of a unique point in the plane.

Output

Output the total number of unique 'T's contained within the given points.

Note that a single point can contribute to multiple 'T' sets. Additionally, any orientation of a 'T' (vertical, horizontal, or upside-down) is acceptable to Ice-T, so include them all in your total.

ExampleInput
11
5 10
7 6
7 4
7 2
1 8
3 8
1 6
3 6
2 4
2 6
5 8
Output
3

加入题单

上一题 下一题 算法标签: