Problem H
Park Management
Imagine you are developing a management system for Halifax’s Parks Department. Halifax has several non-overlapping parks, each defined by simple polygonal boundary on a $2\textrm{D}$ coordinate plane. Your task is to create a program that determines whether points in the plane (representing visitors’ locations) are inside any of the parks, or on the boundary of any of the parks. This functionality will help the Parks Department manage resources, plan events, and ensure the safety of visitors.
Input
The first input line contains two space-separated integers, $n$ $(1 \leq n \leq 50),$ the number of parks, and $m$ $(1 \leq m \leq 100),$ the number of query points. This is followed by $n$ sections, each describing one of the parks (which are numbered $1, 2, \ldots , n$ by the Parks Department, in the order given). A park description begins with a line containing an integer, $k$ $(3 \leq k \leq 500),$ the number of vertices in the polygon defining the park’s boundary. This is followed by $k$ lines, each containing two space-separated integers, the $x$ and $y$ coordinates of one of the polygon’s vertices. The $k$ vertices are distinct, and are given in counterclockwise order. The polygon does not self-intersect, and no three consecutive vertices on the polygon’s boundary are collinear. In addition, no two polygons intersect, and no polygon is contained inside another polygon. The $n$ park descriptions are followed by $m$ lines, each of which contains two space-separated integers, the $x$ and $y$ coordinates of a query point. All vertex and query point coordinates satisfy $-10^6 \leq x,y \leq 10^6.$
Output
Output $m$ lines, one per query. Print “Inside Park p” if the query point is in the interior of Park p, print “Get off the fence of Park p” if the query point lies on the boundary of Park p (in both cases, with the appropriate value of p), and print “Outside any park” otherwise.
| Sample Input 1 | Sample Output 1 |
|---|---|
1 3 3 0 0 3 0 0 3 -1 -1 1 1 0 0 |
Outside any park Inside Park 1 Get off the fence of Park 1 |
| Sample Input 2 | Sample Output 2 |
|---|---|
4 4 7 2 1 3 3 5 3 6 1 7 1 4 7 1 1 12 12 1 12 3 11 3 11 2 9 2 9 6 11 6 11 5 12 5 12 7 8 7 8 1 8 17 5 17 6 16 7 13 7 13 1 14 1 14 4 16 4 12 22 3 21 3 21 2 19 2 19 6 21 6 21 5 22 5 22 7 18 7 18 1 22 1 15 6 20 6 20 4 5 5 |
Inside Park 3 Get off the fence of Park 4 Outside any park Get off the fence of Park 1 |
