2366. New Island

单点时限: 2.0 sec

内存限制: 256 MB

A new island has been discovered. A team of architects has worked hard and proposed a road plan to connect important parts of this new island. Due to lack of fund, we are to modify the design to come up with an affordable one.

In the proposed plan, each road has a unique id between 1 and E (the number of roads) and a cost that is unbelievably equal to 2^id. So, the costs are distinct powers of two. We want to eliminate some of the roads from the plan to get the minimum overall cost while all places are still connected. But, we should not eliminate as many roads as we want. The constraint is that in the new road plan the distance between any two places cannot become more than twice as their distance in the original plan. The distance between two places is the minimum number of roads connecting them. The original road plan is given to you in form of a graph and you are asked to find the most economic road elimination according to the constraint.

输入格式

There are multiple test cases in the input. Each test case is started with a line containing two integers N (1 ≤ N ≤ 200) and E, the number of vertices (places) and edges (roads) respectively. The specification of the roads comes on the next E lines. The ith line contains two numbers vi and ui which means that the road with id i is between places vi and ui. The input is terminated by a line containing two zero numbers.

输出格式

For each test case, write the number of eliminated roads followed by the increasing list of their ids on a single line.

样例

Input
4 5
1 2
3 1
4 1
4 2
3 4
3 3
1 2
2 3
3 1
0 0
Output
2 4 5
1 3

1 人解决,1 人已尝试。

1 份提交通过,共有 1 份提交。

8.9 EMB 奖励。

创建: 15 年,9 月前.

修改: 6 年,10 月前.

最后提交: 10 年前.

来源: Tehran 2007-2008

题目标签