0204. Burning bridges
Имя входного файла: | bridges.in |
Имя выходного файла: | bridges.out |
Ограничение по времени: | 2 s |
Ограничение по памяти: | 64 megabytes |
Ferry Kingdom is a nice little country located on N islands that are connected by M bridges. All bridges are very beautiful and are loved by everyone in the kingdom. Of course, the system of bridges is designed in such a way that one can get from any island to any other one.
But recently the great sorrow has come to the kingdom. Ferry Kingdom was conquered by the armies of the great warrior Jordan and he has decided to burn all the bridges that connected the islands. This was a very cruel decision, but the wizards of Jordan have advised him no to do so, because after that his own armies would not be able to get from one island to another. So Jordan decided to burn as many bridges as possible so that is was still possible for his armies to get from any island to any other one.
Now the poor people of Ferry Kingdom wonder what bridges will be burned. Of course, they cannot learn that, because the list of bridges to be burned is kept in great secret. However, one old man said that you can help them to find the set of bridges that certainly will not be burned.
So they came to you and asked for help. Can you do that?
Input file
The first line of the input file contains N and M – the number of islands and bridges in Ferry Kingdom respectively (2 ≤ N ≤ 10,000, 1 ≤ M ≤ 100,000). Next M lines contain two different integer numbers each and describe bridges. Note that there can be several bridges between a pair of islands.
Output file
On the first line of the output file print K – the number of bridges that will certainly not be burned. On the second line print K integers – the numbers of these bridges. Bridges are numbered starting from one, as they are given in the input file.
Examples:
bridges.in | bridges.out |
---|---|
6 7 1 2 2 3 2 4 5 4 1 3 4 5 3 6 | 2 3 7 |
Источник: Petrozavodsk Winter 2004. Andrew Stankevich Contest 4, Friday, January 30
Автор: Andrew Stankevich
Обсудить Отправить решение
Версия для печати