Polygonal Query
Time limit1sMemory limit512 MB
Points are added one at a time, and for each query the task is to report whether the clockwise or counterclockwise hull path between two hull vertices passes more hull points.
Problem
Let be a set of points on a 2-dimensional plane. Initially, is an empty set. Let convexHull() be the subset of that contains the vertices of the convex hull of , with no three collinear points.
There are queries. Each query is one of the following two types.
- add(, ): Adds the point (, ) to . No two points share the same coordinate or the same coordinate.
- findHeavy(, , , ): The points (, ) and (, ) are distinct points of convexHull(). This query is only called when convexHull() has at least three points. A robot is at (, ) and wants to go to (, ). The robot can only move along the edges of the convex hull. Let be the number of points of convexHull() that the robot passes when it moves clockwise, and let be the number it passes when it moves counterclockwise. If , output "CW". Otherwise, output "CCW".
Input
The first line contains an integer (). The next lines each contain three or five integers.
- If the -th query is add(, ), the -th line is 0 ().
- If the -th query is findHeavy(, , , ), the -th line is 1 ().
Output
For each findHeavy query, print the answer on its own line.