QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 1024 MB Total points: 100

#3746. 千万别用树套树

الإحصائيات

Bobo 精通数据结构!他想维护一个线段的集合 $S$。初始时,$S$ 为空。他会依次进行 $q$ 次操作,操作有 $2$ 种。

  • 类型 $1$:给出 $l, r$,向集合 $S$ 中插入线段 $[l, r]$.
  • 类型 $2$:给出 $l, r$,询问满足 $[x, y] \in S$ 且 $x \leq l \leq r \leq y$ 的线段 $[x, y]$ 数量。

帮 Bobo 求出每次询问的答案。

输入格式

输入文件包含多组数据,请处理到文件结束。

每组数据的第一行包含 $2$ 个整数 $n$ 和 $q$. 其中 $n$ 表示操作中 $r$ 的最大值。

接下来 $q$ 行中的第 $i$ 行包含 $3$ 个整数 $t_i, l_i, r_i$,表示第 $i$ 个操作属于类型 $t_i$,对应的参数是 $l_i$ 和 $r_i$.

输出格式

对于每个类型 $2$ 的询问,输出 $1$ 个整数表示对应的数量。

样例输入

1 2
1 1 1
2 1 1
4 4
1 1 4
2 2 3
1 1 4
2 2 3

样例输出

1
1
2

数据范围

  • $1 \leq n, q \leq 10^5$
  • $t_i \in \{1, 2\}$
  • $1 \leq l_i \leq r_i \leq n$
  • 对于 $t_i = 2$ 的操作,$r_i - l_i \leq 2$ 成立。
  • 数据组数不超过 $10$.
About Issues

We understand that our problem archive is not perfect. If you find any issues with the problem, including the statement, scoring configuration, time/memory limits, test cases, etc.

You may use this form to submit an issue regarding the problem. A problem moderator will review your issue and proceed it properly.

STOP! Before you submit an issue, please READ the following guidelines:

  1. This is not a place to publish a discussion, editorial, or requests to debug your code. Your issue will only be visible by you and problem moderators. Other users will not be able to view or reply your issues.
  2. Do not submit duplicated issues. If you have already submitted one, please wait for an moderator to review it. Submitting multiple issues will not speed up the review process and might cause your account to be banned.
  3. Issues must be filed in English or Chinese only.
  4. Be sure your issue is related to this problem. If you need to submit an issue regarding another problem, contest, category, etc., you should submit it to the corresponding page.

Active Issues 0

No issues in this category.

Closed/Resolved Issues 0

No issues in this category.