QOJ.ac

QOJ

時間限制: 2 s 記憶體限制: 64 MB 總分: 10

#10673. 规划道路施工 [A]

统计

Bytetown 最近开始了道路施工工程。施工的开始限制了城内的交通,几条街道已经被封闭。有人声称城镇的某些部分已经完全无法通行,然而由于缺乏道路施工的协调员,无法对这些信息进行可靠的核实。

为了能够控制局势,Bytetown 市长任命 Byteman 为计算机辅助道路施工协调部门的负责人。已经开始的道路施工无法中途停止,但道路施工预算中仍有一些资金,且有严格的支出期限。因此,市长要求 Byteman 列出一份可以额外(同时)封闭的街道清单,且不能进一步限制城内的通行能力。换句话说,如果当前从一个路口可以到达另一个路口,那么在封闭 Byteman 清单中的街道后,这一连通性应当保持不变。

起初,Byteteman 想要找到最大的此类清单,但他无法成功完成这项任务。因此,他决定寻找这样一组街道:在不切断任何当前连通的路口对之间的通行能力的前提下,无法再向该集合中添加任何其他街道。请编写一个程序来帮助 Byteman 准备所要求的街道清单。

输入格式

标准输入的第一行包含两个整数 $n$ 和 $m$ ($1 \le n \le 5\,000$, $1 \le m \le 100\,000$),分别表示城内的路口数量和连接它们的单向街道数量。路口编号从 $1$ 到 $n$。接下来的 $m$ 行包含各条街道的描述;其中第 $i$ 行包含第 $i$ 条街道的描述,形式为一对整数 $a_{i}, b_{i}$ ($1 \le a_{i}, b_{i} \le n$, $a_{i} \neq b_{i}$)。该对整数表示存在一条从路口 $a_{i}$ 到路口 $b_{i}$ 的单向街道。每对有序对在输入中最多出现一次。城内最初的道路施工开始时没有经过适当的准备,因此对于当前道路网络的形状不应做任何假设。

输出格式

程序应在标准输出的第一行输出一个整数 $k$,表示 Byteman 清单中街道的数量。接下来的 $k$ 行应包含应被封闭的街道编号。街道按照输入中的顺序从 $1$ 到 $m$ 编号。

如果有多个正确答案,输出其中任意一个即可。

样例

输入 1

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

输出 1

2
2
6

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.