2029: Professor's task
Description
Once a walrus professor Plato asked his programming students to perform the following practical task.
The students had to implement such a data structure that would support a convex hull on some set of points S. The input to the program had q queries of two types:
1. Add a point with coordinates (x,y) into the set S. Note that in this case the convex hull of S could have changed, and could have remained the same.
2. Say whether a point with coordinates (x,y) belongs to an area limited by the convex hull, including the border.
All the students coped with the task. What about you?
The first line contains an integer q (4≤q≤105).
Then follow q lines in the following way: "t x y", where t is the query type (1 or 2), and (x,y) are the coordinates of the point (-106≤x,y≤106, x and y are integers).
There is at least one query of type 2.
It is guaranteed that the three queries of the first type follow first and the points given in the queries form a non-degenerative triangle. Also all the points added in S are distinct.
For each query of the second type print one string containing "YES", if the point lies inside the convex hull or on its border. Otherwise, print "NO".
8
1 0 0
1 2 0
1 2 2
2 1 0
1 0 2
2 1 1
2 2 1
2 20 -1
YES
YES
YES
NO