CF1883D.In Love

普及/提高-

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

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

  • ++ ll rr — Add the segment (l,r)(l, r) to the multiset,
  • −- ll rr — Remove exactly one segment (l,r)(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)(l, r) and (a,b)(a, b) do not intersect if there does not exist a point xx such that l≤x≤rl \leq x \leq r and a≤x≤ba \leq x \leq b.

最初,你有一个空的线段多重集合。你需要处理 qq 个操作,操作分为两类:

  • ++ ll rr — 将线段 (l,r)(l, r) 加入多重集合;
  • −- ll rr — 从多重集合中恰好移除一个线段 (l,r)(l, r)(保证该线段一定存在于多重集合中)。

每次操作后,你需要判断多重集合中是否存在一对不相交的线段。线段 (l,r)(l, r) 与 (a,b)(a, b) 不相交,当且仅当不存在实数点 xx 同时满足 l≤x≤rl \leq x \leq r 和 a≤x≤ba \leq x \leq b。

输入格式

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

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

每个测试用例的第一行包含一个整数 qq(1≤q≤1051 \leq q \leq 10^5),表示操作的次数。

接下来的 qq 行描述两种类型的操作:若为添加操作,则格式为 ++ ll rr;若为删除操作,则格式为 −- ll rr(其中 1≤l≤r≤1091 \leq l \leq r \leq 10^9)。

输出格式

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.

每次操作后,如果多重集中存在一对不相交的线段,则输出 "YES";否则输出 "NO"。

答案的大小写不限(大写或小写均可)。例如,字符串 "yEs"、"yes"、"Yes" 和 "YES" 均被视为肯定回答。

输入输出样例

  • 输入#1

    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

    输出#1

    NO
    YES
    YES
    YES
    YES
    YES
    NO
    NO
    YES
    NO
    NO
    NO

说明/提示

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

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

在示例中,执行第二次、第三次、第四次和第五次操作后,存在一对不相交的线段 (1,2)(1, 2) 和 (3,4)(3, 4)。
随后我们恰好移除其中一条线段 (3,4)(3, 4),而此时共有两条线段。因此,该操作后的答案也存在。

输入解题思路,AI测评打分。不知道怎么写?

首页