atcoder#ABC251G. [ABC251G] Intersection of Polygons
[ABC251G] Intersection of Polygons
Score : points
Problem Statement
The vertices of a convex -gon in an -plane are given as in the counterclockwise order. (Here, the positive direction of the -axis is right, and the positive direction of the -axis is up.)
Based on this polygon , we consider convex -gons . For , the polygon is obtained by shifting in the positive direction of the -axis by and in the positive direction of the -axis by . In other words, is a convex -gon whose vertices are $(x_1+u_i, y_1+v_i), (x_2+u_i, y_2+v_i), \ldots, (x_N+u_i, y_N+v_i)$.
For each of points , determine if "the point is contained in all of the polygons ."
Here, we regard a point is also contained in a polygon if the point is on the polygon's boundary.
Constraints
- All values in input are integers.
- forms a convex -gon in the counterclockwise order.
- Each interior angle of the polygon is less than degrees.
Input
Input is given from Standard Input in the following format:
Output
Print lines. For , the -th line should contain Yes
if point is contained in all of the polygons ; it should contain No
otherwise.
5
-2 -3
0 -2
1 0
0 2
-2 1
2
0 1
1 0
6
0 0
1 0
0 1
1 1
-1 -1
-1 -2
Yes
No
Yes
Yes
Yes
No
Polygon is a pentagon (-gon) whose vertices are .
- Polygon is a pentagon (-gon) obtained by shifting in the positive direction of the -axis by and in the positive direction of the -axis by , so its vertices are .
- Polygon is a pentagon (-gon) obtained by shifting in the positive direction of the -axis by and in the positive direction of the -axis by , so its vertices are .
Thus, the following lines should be printed.
- The -st line should be
Yes
because is contained in both and . - The -nd line should be
No
because is contained in but not in . - The -rd line should be
Yes
because is contained in both and . - The -th line should be
Yes
because is contained in both and . - The -th line should be
Yes
because is contained in both and . - The -th line should be
No
because is contained in but not in .
Note that a point on the boundary of a polygon is also considered to be contained in the polygon.
10
45 100
-60 98
-95 62
-95 28
-78 -41
-54 -92
-8 -99
87 -94
98 23
87 91
5
-57 -40
-21 -67
25 39
-30 25
39 -20
16
4 5
-34 -8
-63 53
78 84
19 -16
64 9
-13 7
13 53
-20 4
2 -7
3 18
-12 10
-69 -93
2 9
27 64
-92 -100
Yes
Yes
No
No
Yes
No
Yes
No
Yes
Yes
Yes
Yes
No
Yes
No
No