310764: CF1883D. In Love

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

D. In Lovetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard output

Initially, you have an empty multiset of segments. You need to process $q$ operations of two types:

  • $+$ $l$ $r$ — Add the segment $(l, r)$ to the multiset,
  • $-$ $l$ $r$ — Remove exactly one segment $(l, r)$ from the multiset. It is guaranteed that this segment exists in the multiset.

After each operation, you need to determine if there exists a pair of segments in the multiset that do not intersect. A pair of segments $(l, r)$ and $(a, b)$ do not intersect if there does not exist a point $x$ such that $l \leq x \leq r$ and $a \leq x \leq b$.

Input

The first line of each test case contains an integer $q$ ($1 \leq q \leq 10^5$) — the number of operations.

The next $q$ lines describe two types of operations. If it is an addition operation, it is given in the format $+$ $l$ $r$. If it is a deletion operation, it is given in the format $-$ $l$ $r$ ($1 \leq l \leq r \leq 10^9$).

Output

After each operation, print "YES" if there exists a pair of segments in the multiset that do not intersect, and "NO" otherwise.

You can print the answer in any case (uppercase or lowercase). For example, the strings "yEs", "yes", "Yes", and "YES" will be recognized as positive answers.

ExampleInput
12
+ 1 2
+ 3 4
+ 2 3
+ 2 2
+ 3 4
- 3 4
- 3 4
- 1 2
+ 3 4
- 2 2
- 2 3
- 3 4
Output
NO
YES
YES
YES
YES
YES
NO
NO
YES
NO
NO
NO
Note

In the example, after the second, third, fourth, and fifth operations, there exists a pair of segments $(1, 2)$ and $(3, 4)$ that do not intersect.

Then we remove exactly one segment $(3, 4)$, and by that time we had two segments. Therefore, the answer after this operation also exists.

Output

题目大意:
初始时,你有一个空的多段集合。您需要处理两种类型的$$$ q$$$ 操作:
1. $$$+$$$ $$$l$$$ $$$r$$$ — 向集合中添加一个段 $$$(l, r)$$$,
2. $$$-$$$ $$$l$$$ $$$r$$$ — 从集合中删除一个确切的段 $$$(l, r)$$$。保证此段存在于集合中。

每次操作后,您需要确定集合中是否存在两个不交叉的段。如果不存在一个点 $$$x$$$ 使得 $$$l \leq x \leq r$$$ 且 $$$a \leq x \leq b$$$,则两个段 $$$(l, r)$$$ 和 $$$(a, b)$$$ 不相交。

输入数据格式:
每个测试用例的第一行包含一个整数 $$$q$$$($$$1 \leq q \leq 10^5$$$)— 操作的数量。

接下来的 $$$q$$$ 行描述两种类型的操作。如果是添加操作,格式为 $$$+$$$ $$$l$$$ $$$r$$$。如果是删除操作,格式为 $$$-$$$ $$$l$$$ $$$r$$$($$$1 \leq l \leq r \leq 10^9$$$)。

输出数据格式:
每次操作后,如果集合中存在两个不相交的段,则打印“YES”,否则打印“NO”。

你可以以任何大小写打印答案。例如,字符串“yEs”、“yes”、“Yes”和“YES”将被识别为肯定答案。题目大意: 初始时,你有一个空的多段集合。您需要处理两种类型的$$$ q$$$ 操作: 1. $$$+$$$ $$$l$$$ $$$r$$$ — 向集合中添加一个段 $$$(l, r)$$$, 2. $$$-$$$ $$$l$$$ $$$r$$$ — 从集合中删除一个确切的段 $$$(l, r)$$$。保证此段存在于集合中。 每次操作后,您需要确定集合中是否存在两个不交叉的段。如果不存在一个点 $$$x$$$ 使得 $$$l \leq x \leq r$$$ 且 $$$a \leq x \leq b$$$,则两个段 $$$(l, r)$$$ 和 $$$(a, b)$$$ 不相交。 输入数据格式: 每个测试用例的第一行包含一个整数 $$$q$$$($$$1 \leq q \leq 10^5$$$)— 操作的数量。 接下来的 $$$q$$$ 行描述两种类型的操作。如果是添加操作,格式为 $$$+$$$ $$$l$$$ $$$r$$$。如果是删除操作,格式为 $$$-$$$ $$$l$$$ $$$r$$$($$$1 \leq l \leq r \leq 10^9$$$)。 输出数据格式: 每次操作后,如果集合中存在两个不相交的段,则打印“YES”,否则打印“NO”。 你可以以任何大小写打印答案。例如,字符串“yEs”、“yes”、“Yes”和“YES”将被识别为肯定答案。

加入题单

上一题 下一题 算法标签: