#P6679. Polygon Coloring Challenge
Polygon Coloring Challenge
Polygon Coloring Challenge
Mirko and Slavko are spending their free time with polygons and the new season of The Biggest Loser. Mirko has drawn a convex polygon with an even number of vertices, denoted by \(N\). For each pair of opposite sides (two sides are opposite if there are \(\frac{N}{2} - 1\) sides between them), Slavko draws the infinite lines that contain those sides and colors them along with the whole region of the plane between these two lines that contains the polygon. Afterwards, Mirko challenges Slavko with \(Q\) query points. For each query point, you need to determine whether it lies in at least one of the colored regions. Note that a point on the boundary of a colored region is considered colored.
Explanation: For each pair of opposite sides, the colored region is the closed strip (band) between the two lines supporting these sides. A point is colored if it lies in at least one of these strips.
inputFormat
The first line contains two space-separated integers \(N\) and \(Q\), where \(N\) (an even integer) is the number of vertices of the polygon and \(Q\) is the number of query points.
The next \(N\) lines each contain two integers \(x\) and \(y\), representing the coordinates of the polygon's vertices in order (either clockwise or counterclockwise). It is guaranteed that the polygon is convex.
The following \(Q\) lines each contain two integers \(x\) and \(y\), representing a query point.
outputFormat
For each query, output a single line containing YES
if the point lies in one of the colored regions; otherwise, output NO
.
sample
4 5
0 0
4 0
4 3
0 3
2 1
-1 1
5 5
4 2
-2 4
YES
YES
NO
YES
NO
</p>