QOJ.ac

QOJ

時間限制: 4.0 s 記憶體限制: 256 MB 總分: 100

#10036. 搭建弹珠轨道

统计

Jonathan 希望你能在墙上安装一些弹珠轨道供他玩耍。每一条轨道都是一根笔直的塑料条,一侧有一个小凹槽,供弹珠在其中滚动。在询问了 Jonathan 他希望如何安装这些轨道后,他花了 15 分钟用蜡笔为你画了一张蓝图。在他把蓝图交给你之后,你告诉他,你无法建造两条在内部点相交的轨道。Jonathan 对此思考了片刻,然后修改了他的蓝图。但他并没有从根本上解决问题,而是决定将所有轨道从 1(他最喜欢的)到 $n$(他最不喜欢的)进行编号。

第一个样例(原始蓝图)。

现在你的任务是确定要建造哪些轨道。你决定按照从最喜欢到最不喜欢的顺序检查所有轨道,如果某条轨道与你已经安装在墙上的轨道不相交,就建造它。

输入格式

第一行包含一个整数 $n$ ($1 \le n \le 6 \cdot 10^4$),表示蓝图中的弹珠轨道数量。

接下来的 $n$ 行,每行包含四个整数 $x_1, y_1, x_2, y_2$ ($-10^5 \le x_1, y_1, x_2, y_2 \le 10^5$ 且 $x_1 \neq x_2$)。这些坐标表示蓝图中从 $(x_1, y_1)$ 到 $(x_2, y_2)$ 的一条弹珠轨道。

轨道按从最喜欢到最不喜欢的顺序给出。任意两条不同的轨道最多相交于一点。

输出格式

第一行输出一个整数 $k$,表示要建造的轨道数量。下一行输出 $k$ 个整数,按升序排列,表示要建造的轨道编号。

样例

样例 1

6
3 2 5 4
0 4 4 0
2 1 6 1
5 4 7 2
0 3 5 3
4 2 6 0
4
1 2 4 6

样例 2

2
0 0 2 2
1 1 2 0
2
1 2

样例 3

10
-30428 50667 -18028 82591
-19828 85240 -16439 54314
-16439 54314 -13911 33099
-18028 82591 -13739 13271
-13911 33099 -11978 -46941
-13739 13271 14783 13050
-11978 -46941 35511 -79125
35511 -79125 35524 -89845
35524 -89845 67295 -41898
14783 13050 72720 -67171
6
1 3 5 7 8 9

说明

正如你可能已经注意到的,输入格式规定了每条可能的弹珠轨道满足 $x_1 \neq x_2$。这是因为你无法让弹珠在垂直轨道上滚动。

Editorials

IDTypeStatusTitlePosted ByLast UpdatedActions
#617Editorial Open集训队作业 解题报告 by 洪泽Qingyu2026-01-02 23:12:58 Download

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.