QOJ.ac

QOJ

実行時間制限: 2 s メモリ制限: 256 MB 満点: 100

#2392. 点与矩形

統計

你拥有一个空的无限二维平面和 $q$ 次查询。查询有两种类型:

  • 1 x y — 在平面上添加一个坐标为 $(x, y)$ 的点。
  • 2 x1 y1 x2 y2 — 添加一个左下角坐标为 $(x_1, y_1)$,右上角坐标为 $(x_2, y_2)$ 的矩形。该矩形的面积可以为零,矩形也可以退化为一个点。

矩形和点可能会重叠,即不保证这些图形是互不相同的。 此外,为了完成这些查询,在每次查询后,你需要输出点落在矩形边界上或矩形内部的矩形与点对的数量。

输入格式

第一行包含一个整数 $q$ ($1 \le q \le 10^5$),表示查询的数量。 接下来的 $q$ 行,每行包含一个查询:

  • 1 x y ($1 \le x, y \le 10^9$) — 在平面上添加一个坐标为 $(x, y)$ 的点。
  • 2 x1 y1 x2 y2 ($1 \le x_1 \le x_2 \le 10^9, 1 \le y_1 \le y_2 \le 10^9$) — 添加一个左下角坐标为 $(x_1, y_1)$,右上角坐标为 $(x_2, y_2)$ 的矩形。

输出格式

你需要输出 $q$ 行,第 $i$ 行必须包含一个整数,表示点落在矩形边界上或矩形内部的矩形与点对的数量。

样例

输入 1

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

输出 1

0
0
0
3
4

输入 2

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

输出 2

0
0
2
4

输入 3

7
1 5 5
1 5 5
1 5 5
2 2 2 9 9
2 1 1 5 5
2 1 1 2 2
1 2 2

输出 3

0
0
3
6
6
9

说明

第一个样例的解释: 在第一次查询后,我们有一个坐标为 $(2, 3)$ 的点,此时还没有任何矩形,因此没有点与矩形的配对。 在第二次查询后,我们仍然没有矩形,因此没有配对。 第三次查询后依然没有矩形。 在第四次查询中,我们添加了一个左下角坐标为 $(1, 1)$,右上角坐标为 $(5, 5)$ 的矩形。之前添加的所有三个点都落在这个矩形内部,因此我们有三个配对。 在第五次查询后,我们有四个配对:前三次查询添加的点都落在了第四次查询添加的矩形内部(前三个配对),以及第二次查询添加的点落在了第五次查询添加的矩形内部(第四个配对)。

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.