QOJ.ac

QOJ

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

#3705. Right turn

Statistics

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

Discussions

About Discussions

The discussion section is only for posting: Editorials, 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. Submitting multiple issues may cause your account to be banned.
  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.