QOJ.ac

QOJ

時間限制: 1 s 記憶體限制: 2048 MB 總分: 100

#8379. Odd

统计

Given a directed graph, find the number of edges such that removing these edges eliminates all cycles in the graph.

Input

The first line contains two integers, $n$ and $m$, representing the number of vertices and the number of edges, respectively.

Following this are $m$ lines, each containing two node indices $u$ and $v$ (starting from 1), representing a directed edge from $u$ to $v$.

To avoid unnecessary complications, the data does not contain self-loops or multiple edges.

Output

The first line outputs the number of edges $a$ that satisfy the requirement.

Following this are $a$ lines, each outputting the index (starting from 1) of an edge that satisfies the requirement, as given in the input. All indices must be sorted in ascending order.

Examples

Input 1

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

Output 1

2
1
3

Note 1

As shown in the figure, both orange edges satisfy the requirement.

Input 2

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

Output 2

0

Note 2

There are two cycles in the graph, which do not share any edges. Removing any edge from one cycle leaves the other cycle intact.

Constraints

All data satisfies $1 \le n \le 50\,000$, $1 \le m \le 200\,000$.

35% of the data satisfies $n \le 500$, $m \le 50\,000$.

25% of the data satisfies $n \le 500$, $m \le 1\,500$.

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.