#P14615. [2019 KAIST RUN Fall] Capital
[2019 KAIST RUN Fall] Capital
题目描述
You are given cities connected by roads. Cities are numbered from 1 through , and roads are numbered from 1 through . For each pair of cities, there is a sequence of roads that connects those two cities. Road has the length kilometre and connects city and city bidirectionally. Every road has a positive length, so . Unfortunately, you have forgotten the length of each road.
You observed that, for each road, all people on road are going from to , in a single direction. So, you assumed the hypothesis as follows:
- There is a capital city called .
- People are moving from the capital city to other cities.
- People try to move in the shortest path. So the length of the shortest path from to is less than or equal to the length of the shortest path from to .
Can you find the capital city which meets the criteria when you can assign the length of each road to be any positive real number? You may assume that there is at least one city that meets the criteria.
输入格式
The first line of the input contains two integers () and ().
In the -th line of next lines, and are given. ()
There are no loops or multiple edges. Formally, , and .
输出格式
In the first line, print the number of possible capital cities, .
In the second line, print space-separated integers which denotes all possible cities for the capital, in increasing order.
2 1
1 2
1
1
京公网安备 11011102002149号