QOJ.ac

QOJ

Time Limit: 0.3 s Memory Limit: 32 MB Total points: 100

#949. 道路

Statistics

Treeland 政府想要建造一个新的道路网络。Treeland 共有 $2N$ 座城市。该道路网络尚未完成的规划中已经包含了 $N$ 条路段,每一条路段都用直线连接两座城市。任意两条路段都没有公共点(包括端点)。

你的任务是确定 $N - 1$ 条额外的路段,以满足以下条件:

  1. 每一条新路段必须用直线连接两座城市。
  2. 如果两条路段(新路段或旧路段)有公共点,则该点必须是这两条路段的公共端点。
  3. 道路网络连接所有城市:对于每一对城市,都存在一条由路段组成的路径连接这两座城市。

输入格式

第一行包含一个整数 $N$,表示现有路段的数量。接下来的 $N$ 行,每行包含四个整数 $x_1, y_1, x_2, y_2$,其中 $(x_1, y_1)$ 和 $(x_2, y_2)$ 是该路段两个端点的坐标。

输出格式

你应该输出 $N - 1$ 行,每行包含四个整数 $x_1, y_1, x_2, y_2$,其中 $(x_1, y_1)$ 和 $(x_2, y_2)$ 是新路段两个端点的城市坐标。如果存在多种解,输出其中任意一种即可。

数据范围

$2 \le N \le 10^5$ $-10^7 \le x_i, y_i \le 10^7$

子任务

子任务 分值 约束条件
1 0 样例
2 15 所有输入路段均为垂直
3 15 每对输入路段均平行
4 15 每个输入路段均为水平或垂直
5 15 $N \le 10\,000$
6 40 无额外约束

样例

输入 1

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

输出 1

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

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.