Master of Both V
시간 제한5초메모리 제한2048 MB
세그먼트의 동적 집합을 유지하면서 각 갱신 후 모든 세그먼트가 하나의 볼록 다각형의 변 위에 놓일 수 있는지 판정한다.
문제
Prof. Chen is the master of data structure and computational geometry. Recently, he taught Putata and Budada the definition of convex polygon. A convex polygon is a simple polygon (i.e., no two vertices coincide and no two edges intersect unless two continuous edges intersect at a vertex) with all interior angles strictly less than .
Putata and Budada solved the convex checker problem, but Prof. Chen asked them to go further, which they have to maintain a multiset of segments , supporting the following two types of inquiries:
- , insert segment with endpoints to the multiset .
- , erase the segment inserted in the -th inquiry. It is guaranteed that the -th inquiry is an inserting inquiry and the corresponding segment is currently in the multiset.
After each inquiry, Putata and Budada needs to answer if there exists a convex polygon , where the vertices of the convex polygon are in counter clockwise order, satisfying that for all segment , exists such that . For two segments , we say if and only if for all point , satisfying that .
Please help Putata and Budada to solve this problem.
입력
Each test contains multiple test cases. The first line contains a single interger (), denoting the number of test cases.
For each test case, the first line contains an integer (), denoting the number of inquiries.
Each of the folowing lines contains one inquiry. The inquiry begins with a character ().
If , then four integers () follows, denoting an inserting inquiry. It is guaranteed that or .
Otherwise an integer () follows, denoting an erasing inquiry. It is guaranteed that the -th inquiry is an inserting inquiry and the corresponding segment is currently in the multiset.
It is guaranteed that the sum of does not exceed .
출력
For each test case, print a string consisting of '0' and '1' in one line. The -th character is '1' if the answer is true after the -th inquiry, otherwise it is '0'.