Courtney and convex polygon

0

0 votes
Linear Algebra, Hard, Mathematics
Problem

Courtney has a convex polygon with n vertices. She define the point with coordinates x and y as (x,y). Courtney wants to do three types of queries:

  • 1 x y - rotate polygon on 90 degrees in counterclockwise order around point (x,y)
  • 2 x y - reflect polygon through point (x,y)
  • 3 x y - check if point (x,y) is inside polygon

But it's too difficult for Courtney. Help her!

INPUT
The first line of input contains two integers n and q (3n100000,1q300000) - number of vertices in polygon and number of queries.

Then n lines follow. The i-th of these lines contains two integers xi and yi (100000000xi,yi100000000) - the i-th point of polygon. Points are given in counterclockwise order. There no such three points that would lie on the same polygon side. The area of polygon is greater than 0.

Then q lines follow. The i-th of these lines contains three integers typei, xi, yi (1typei3,100000000<=xi,yi<=100000000) - parameters of i-th query.

OUTPUT
For each query of the third type print "Yes" (without quoters) if point (xi,yi) lies in polygon and "No" (without quoters) otherwise.

NOTES
In this problem point lies inside polygon if it lies strictly inside polygon or lies on polygon border.

Sample Input
3 8
3 0
0 4
-2 -2
3 3 0
3 -2 2
2 0 1
3 3 0
3 -2 2
1 2 0
3 1 -3
3 0 0
Sample Output
Yes
No
No
Yes
Yes
No
Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation

enter image description here

  • ABC - is polygon before changes
  • EFG - is ABC after reflect it through D
  • IKJ - is EFG after rotate it on 90 degrees in counterclockwise order around H
Editor Image

?