QOJ.ac

QOJ

Time Limit: 2 s Memory Limit: 256 MB Total points: 100

#21223. Bovine Bridge Battle

Statistics

Each of Farmer John's $N$ $4 \le N \le 1,000$ cows is patiently waiting in the main pasture with cow $i$ at point with integer coordinates ($X_{i}$, $Y_{i}$) $-1,000,000,000 \le X_{i} \le 1,000,000,000; -1,000,000,000 \le Y_{i} \le 1,000,000,000$.

The cows wish to form into groups of four in order to play Bridge, their new favorite card game. Each group must satisfy an important constraint: four cows are allowed to team up if and only if there exists some point $X$ somewhere in the plane (and not coincident with any of the four points of the potential group of four) such that rotating any of the group's cows 180 degrees about that point $X$ gives the position of some other cow in the group.

Please help the cows determine the number of sets of four cows that can form a Bridge group.

By way of example, suppose eight cows are standing at eight points:

                  |
                 f*
                  |             a = (-3, 1)    e = (-1, 1)
           b*     |             b = (-2, 2)    f = ( 0, 3)
        a      e  |             c = (-3, 0)    g = ( 2, 0)
         *     *  |             d = (-2, 0)    h = ( 3, 0)
         c  d     |     g  h
---------*--*-----+-----*--*---------
                  |

Then the three legal sets of four cows are {a, b, e, d} (they rotate around point (-2, 1)), {b, c, e, f} (around the point (-1.5, 1.5)), and {c, d, g, h} (around (0,0)).

The supplied locations of the cows given are all distinct, although they are supplied in no particular order. Furthermore, the answer will fit into a signed 32-bit integer.

Input

  • Line 1: A single integer: $N$
  • Lines $2..N+1$: Line $i+1$ contains two space-separated integers: $X_{i}$ and $Y_{i}$

Output

  • Line 1: A single integer that is the number of sets of 4 cows that form valid groups for bridge.

Examples

Input 1

8
-3 0
-2 0
-1 1
0 3
2 0
-3 1
3 0
-2 2

Output 1

3

Problem credits: Richard Ho, 2007

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.