QOJ.ac

QOJ

Time Limit: 2 s Memory Limit: 256 MB Total points: 100

#494. 金矿

Statistics

有 $n$ 座金矿,第 $i$ 座金矿位于坐标 $(x_i, y_i)$。有三家公司:ZeroOneTwo 在这些金矿工作,每座金矿的所有者 $c_i \in \{0, 1, 2\}$ 是已知的。

最近,Flatland 的议会通过了一项新法律,规定只有当金矿位于某公司的领地内时,该公司才能在该金矿工作。每家公司的领地必须是一个边平行于坐标轴的非退化矩形。不同公司的领地不能有非零面积的公共部分(尽管它们可以有公共边界)。

然而,事实证明这三家公司都属于同一家控股公司 Three,因此这三家公司的经理决定划分领地,以使三家公司能够工作的金矿总数最大化。如果金矿位于两个或三个领地的边界上,则其所有者对应的公司都可以开采该金矿。请帮助经理们划分领地。

输入

输入包含多个测试用例。每个测试用例的第一行包含 $n$ ($1 \le n \le 50\,000$)。接下来的 $n$ 行,每行包含三个整数:$x_i, y_i$ 和 $c_i$ ($-10^9 \le x_i, y_i \le 10^9, c_i \in \{0, 1, 2\}$)。

最后一个测试用例后跟 $n = 0$,该行无需处理。所有测试用例的 $n$ 之和不超过 $50\,000$。

输出

对于每个测试用例,输出四行。第一行必须包含 $k$ —— 在划分好公司领地后,能够被开采的金矿的最大数量。接下来的三行必须描述各公司的领地。每个领地由四个整数描述:$x_1, y_1, x_2$ 和 $y_2$ ($-2 \cdot 10^9 \le x_1 < x_2 \le 2 \cdot 10^9, -2 \cdot 10^9 \le y_1 < y_2 \le 2 \cdot 10^9$) —— 这是矩形两个对角的坐标。如果 $c_i = 0$,则位于第一个矩形内的金矿可以被开采;如果 $c_i = 1$,则位于第二个矩形内的金矿可以被开采;如果 $c_i = 2$,则位于第三个矩形内的金矿可以被开采。

样例

输入 1

12
0 0 0
1 0 0
2 0 1
3 0 2
0 1 1
1 1 1
2 1 2
3 1 1
0 2 1
1 2 0
2 2 2
3 2 2
0

输出 1

10
-1 -1 2 0
-1 0 2 3
2 -1 4 3

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.