Movatterモバイル変換


[0]ホーム

URL:


Logo

33438번 -Master of Both V다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
5 초2048 MB111100.000%

문제

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 $\pi$.

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 $S$, supporting the following two types of inquiries:

  • $+$ $px$ $py$ $qx$ $qy$, insert segment with endpoints $(px,py), (qx,qy)$ to the multiset $S$.
  • $-$ $i$, erase the segment inserted in the $i$-th inquiry. It is guaranteed that the $i$-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 $\mathcal{C}$, where the vertices of the convex polygon are $p_0,p_1,p_2,\dots,p_{m-1}$ in counter clockwise order, satisfying that for all segment $u\in S$, exists $j\in\{0,1,2,\dots,m-1\}$ such that $u\subseteq p_jp_{(j+1)\bmod m}$. For two segments $e, f$, we say $e\subseteq f$ if and only if for all point $z\in e$, satisfying that $z\in f$.

Please help Putata and Budada to solve this problem.

입력

Each test contains multiple test cases. The first line contains a single interger $t$ ($1 \leq t \leq 5 \cdot 10^5$), denoting the number of test cases.

For each test case, the first line contains an integer $n$ ($1\leq n\leq 5\cdot 10^5$), denoting the number of inquiries.

Each of the folowing $n$ lines contains one inquiry. The inquiry begins with a character $op$ ($op\in\{+,-\}$).

If $op=+$, then four integers $px, py, qx, qy$ ($-10^9\leq px,py,qx,qy\leq 10^9$) follows, denoting an inserting inquiry. It is guaranteed that $px\neq qx$ or $py \neq qy$.

Otherwise an integer $i$ ($1\leq i\leq n$) follows, denoting an erasing inquiry. It is guaranteed that the $i$-th inquiry is an inserting inquiry and the corresponding segment is currently in the multiset.

It is guaranteed that the sum of $n$ does not exceed $5\cdot 10^5$.

출력

For each test case, print a string consisting of '0' and '1' in one line. The $i$-th character is '1' if the answer is true after the $i$-th inquiry, otherwise it is '0'.

제한

예제 입력 1

48+ 0 0 1 0+ 5 5 1 3+ 2 0 2 1+ 9 7 6 2+ 1 2 2 2- 4+ 0 1 0 2- 25+ 0 0 1 1+ 0 1 1 2+ 0 2 1 3- 2+ 1 1 10 104+ 0 0 1 1+ 0 0 1 0+ 0 0 0 1- 14+ 0 0 1 1+ 0 0 1 1- 1- 2

예제 출력 1

110000011101111011111

힌트

출처

Camp > Petrozavodsk Programming Camp > Winter 2024 > Day 3: ZJU Contest L번

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일:contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호


[8]ページ先頭

©2009-2025 Movatter.jp