QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 1024 MB Total points: 100

#3705. Right turn

統計

frog is trapped in a maze. The maze is infinitely large and divided into grids. It also consists of $n$ obstacles, where the $i$-th obstacle lies in grid $(x_i, y_i)$.

frog is initially in grid $(0, 0)$, heading grid $(1, 0)$. She moves according to The Law of Right Turn: she keeps moving forward, and turns right encountering a obstacle.

The maze is so large that frog has no chance to escape. Help her find out the number of turns she will make.

Input

The input consists of multiple tests. For each test:

The first line contains $1$ integer $n$ ($0 \leq n \leq 10^3$). Each of the following $n$ lines contains $2$ integers $x_i, y_i$. ($|x_i|, |y_i| \leq 10^9, (x_i, y_i) \neq (0, 0)$, all $(x_i, y_i)$ are distinct)

Output

For each test, write $1$ integer which denotes the number of turns, or -1 if she makes infinite turns.

Sample Input

2
1 0
0 -1
1
0 1
4
1 0
0 1
0 -1
-1 0

Sample Output

2
0
-1
About Issues

We understand that our problem archive is not perfect. If you find any issues with the problem, including the statement, scoring configuration, time/memory limits, test cases, etc.

You may use this form to submit an issue regarding the problem. A problem moderator will review your issue and proceed it properly.

STOP! Before you submit an issue, please READ the following guidelines:

  1. This is not a place to publish a discussion, editorial, or requests to debug your code. Your issue will only be visible by you and problem moderators. Other users will not be able to view or reply your issues.
  2. Do not submit duplicated issues. If you have already submitted one, please wait for an moderator to review it. Submitting multiple issues will not speed up the review process and might cause your account to be banned.
  3. Issues must be filed in English or Chinese only.
  4. Be sure your issue is related to this problem. If you need to submit an issue regarding another problem, contest, category, etc., you should submit it to the corresponding page.

Active Issues 0

No issues in this category.

Closed/Resolved Issues 0

No issues in this category.