Inside, Outside, or On the Fence — Solution & Editorial
Ray casting: count edge crossings of a horizontal ray; odd = inside. First test boundary membership exactly (collinear + within the edge's bounding box) using integer cross products.
Complexity: O(NQ)
Watch out: The border must be detected BEFORE the parity test, or on-edge points flip unpredictably.