QOJ.ac

QOJ

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

#5373. Projective Symmetry

Statistics

Given $n$ integer points $(x_i, y_i)$ on a plane, projecting these $n$ points onto a line $l$ forms a multiset $E_l$ of $n$ points. A line $l$ passing through the origin is called "good" if there exists a point $P$ on the line such that $E_l$ is symmetric with respect to $P$.

A multiset of points on a line is symmetric with respect to $P$ if, after removing any points that coincide with $P$, the remaining points can be paired such that each pair is symmetric with respect to $P$.

Find the number of "good" lines.

Note that there may be infinitely many such lines, in which case you should output $-1$.

Input

The first line contains an integer $n$, representing the number of points.

The next $n$ lines each contain two integers $x_i, y_i$, representing the coordinates of the $i$-th point.

$1 \leq n \leq 2\,000$, $|x_i|, |y_i| \leq 10^6$. The data may contain coincident points.

Output

Output a single integer representing the number of "good" lines. If there are infinitely many, output $-1$.

Examples

Input 1

3
1 3
2 1
3 3

Output 1

3

Input 2

6
88 -27
115 34
-147 -298
-106 -229
-9 -128
212 135

Output 2

5

Input 3

2
6666 -2333
2333 6666

Output 3

-1

Subtasks

For subtask 1 ($10\%$), $n \leq 3$.

For subtask 2 ($20\%$), $n \leq 12$.

For subtask 3 ($20\%$), special property 1 is satisfied.

For subtask 4 ($50\%$), no special properties.

Special property 1: $n \geq 100$, there are at most 10 points outside the $y$-axis, then some distinct points are placed randomly on the positive $y$-axis, and their symmetric points with respect to the origin are placed on the negative $y$-axis.

For $100\%$ of the data, $1 \leq n \leq 2\,000$, $|x_i|, |y_i| \leq 10^6$. The data may contain coincident points.

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.