Inside or Outside? - 2 Points
Had enough geometry? No? Well good! Here's some more. You'll be given
the points that define a country and points representing contacts of ours.
Assume for the country that each point is connected to the next by a straight
line segment, and don't forget to connect the first and last points!
Your job? Given that sequence of points (that define the country) and
a set of contact location points, determine if each contact lies inside the
country. Note that general shape of all countries given will be convex, none
will be concave. Also, note that each country will be defined by no more
than 20 points, and there will be no less than 1 and no more than 10 contact
location points.
Note: All numbers will be given as integers.
Input Format
The first line will list how many points are in the polygon (n).
The following (n) lines will hold 2D points that describe the polygon.
After the n points, there will be a collection of points, each of which
is two numbers.
Notes:
- Also, there may be more than one country-contact pair.
- No points will be given that lie on a boundary.
The end of contact-location tests for each country will be separated
by a -1
The end of all countries will be indicated by a second -1.
i.e.
4 (means there are 4 points to define the country)
0 0 (first point is 0, 0)
0 2 (second point is 0, 2)
2 2 (third point is 2, 2)
2 0 (fourth point is 2, 0)
1 1 (first contact lies at 1, 1)
2 3 (next contact lies at 2, 3)
-1 (end of contacts for this country)
-1 (end of countries)
The input file will be called jin07.txt.
Output Format
Given the n points, determine if the single point is inside or outside
the polygon.
If the point is inside the polygon: Point lies inside!
If the point is not inside: Point lies outside!
For each new country, you should insert a blank line between the data.
Example
Input
4
0 0
0 2
2 2
2 0
1 1
-1
-1
Output
Point lies inside!