A12891 | Balanced Removals (Easier)
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
This is an easier version of the problem. In this version, $n \le 2000$ .
There are $n$ distinct points in three-dimensional space numbered from $1$ to $n$ . The $i$ -th point has coordinates $(x_i, y_i, z_i)$ . The number of points $n$ is even.
You'd like to remove all $n$ points using a sequence of $\frac{n}{2}$ snaps. In one snap, you can remove any two points $a$ and $b$ that have not been removed yet and form a perfectly balanced pair. A pair of points $a$ and $b$ is perfectly balanced if no other point $c$ (that has not been removed yet) lies within the axis-aligned minimum bounding box of points $a$ and $b$ .
Formally, point $c$ lies within the axis-aligned minimum bounding box of points $a$ and $b$ if and only if $\min(x_a, x_b) \le x_c \le \max(x_a, x_b)$ , $\min(y_a, y_b) \le y_c \le \max(y_a, y_b)$ , and $\min(z_a, z_b) \le z_c \le \max(z_a, z_b)$ . Note that the bounding box might be degenerate.
Find a way to remove all points in $\frac{n}{2}$ snaps.
There are $n$ distinct points in three-dimensional space numbered from $1$ to $n$ . The $i$ -th point has coordinates $(x_i, y_i, z_i)$ . The number of points $n$ is even.
You'd like to remove all $n$ points using a sequence of $\frac{n}{2}$ snaps. In one snap, you can remove any two points $a$ and $b$ that have not been removed yet and form a perfectly balanced pair. A pair of points $a$ and $b$ is perfectly balanced if no other point $c$ (that has not been removed yet) lies within the axis-aligned minimum bounding box of points $a$ and $b$ .
Formally, point $c$ lies within the axis-aligned minimum bounding box of points $a$ and $b$ if and only if $\min(x_a, x_b) \le x_c \le \max(x_a, x_b)$ , $\min(y_a, y_b) \le y_c \le \max(y_a, y_b)$ , and $\min(z_a, z_b) \le z_c \le \max(z_a, z_b)$ . Note that the bounding box might be degenerate.
Find a way to remove all points in $\frac{n}{2}$ snaps.
输入格式
The first line contains a single integer $n$ ( $2 \le n \le 2000$ ; $n$ is even), denoting the number of points.
Each of the next $n$ lines contains three integers $x_i$ , $y_i$ , $z_i$ ( $-10^8 \le x_i, y_i, z_i \le 10^8$ ), denoting the coordinates of the $i$ -th point.
No two points coincide.
Each of the next $n$ lines contains three integers $x_i$ , $y_i$ , $z_i$ ( $-10^8 \le x_i, y_i, z_i \le 10^8$ ), denoting the coordinates of the $i$ -th point.
No two points coincide.
输出格式
Output $\frac{n}{2}$ pairs of integers $a_i, b_i$ ( $1 \le a_i, b_i \le n$ ), denoting the indices of points removed on snap $i$ . Every integer between $1$ and $n$ , inclusive, must appear in your output exactly once.
We can show that it is always possible to remove all points. If there are many solutions, output any of them.
We can show that it is always possible to remove all points. If there are many solutions, output any of them.
输入输出样例
输入 #1
6 3 1 0 0 3 0 2 2 0 1 0 0 1 3 0 0 1 0
输出 #1
3 6 5 1 2 4
输入 #2
8 0 1 1 1 0 1 1 1 0 1 1 1 2 2 2 3 2 2 2 3 2 2 2 3
输出 #2
4 5 1 6 2 7 3 8
In the first example, here is what points and their corresponding bounding boxes look like (drawn in two dimensions for simplicity, as all points lie on $z = 0$ plane). Note that order of removing matters: for example, points $5$ and $1$ don't form a perfectly balanced pair initially, but they do after point $3$ is removed.


C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted