Master of Both V
Time limit5sMemory limit2048 MB
After each insertion or deletion, report whether some convex polygon exists that has every segment in the multiset lying on one of its edges.
- Level
Hard10 of 10
- Topics
- Geometry, Segment tree, Sorting
- Solved
- No attempts yet
Problem
Prof. Chen is the master of data structures and computational geometry. Recently, he taught Putata and Budada the definition of a convex polygon. A convex polygon is a simple polygon (that is, no two vertices coincide, and no two edges intersect unless two consecutive edges meet at a vertex) whose interior angles are all strictly less than .
Putata and Budada solved the convex checker problem. Prof. Chen then asked them to go further: maintain a multiset of segments that supports two types of queries.
- : insert the segment with endpoints and into the multiset .
- : erase the segment inserted by the -th query. It is guaranteed that the -th query is an insertion and that its segment is currently in the multiset.
After each query, answer whether there exists a convex polygon with vertices in counterclockwise order such that for every segment , there is some with . For two segments , holds if and only if every point also lies in .
Input
The first line contains a single integer (), the number of test cases.
Each test case starts with a line containing an integer (), the number of queries. Each of the following lines contains one query. A query begins with a character ().
If , four integers () follow. It is guaranteed that or .
Otherwise, an integer () follows. It is guaranteed that the -th query is an insertion and that its segment is currently in the multiset.
The sum of over all test cases does not exceed .
Output
For each test case, print a string of '0' and '1' on one line. The -th character is '1' if the answer is true after the -th query, and '0' otherwise.