#P1841. [JSOI2007] 重要的城市
[JSOI2007] 重要的城市
Description
Students attending the JSOI winter camp recently discovered that, due to road construction on the Nanhang campus cutting off the original route to the computing center, the travel distance increased by nearly one kilometer. However, although construction in front of the cafeteria also blocked the original route to the computing center, it did not increase the distance because an alternative route of the same length could be found. In fact, the key is that the blocked point is a critical junction.
A similar situation occurs in intercity transportation. If certain cities have problems, they may cause inconvenience to traffic between many other cities. Other cities do not affect the traffic between other cities. The JSOI winter camp students found this to be an interesting problem and decided to study it.
They consider a city to be important if: after a city is destroyed, there exist two distinct cities and (with ) such that the shortest distance from to increases (or becomes disconnected). In this case, city is important.
Given a transportation map between cities provided by the coaches, they want to find all important cities. Now please solve this problem.
Input Format
The first line contains two integers and : is the number of cities, and is the number of roads.
The next lines each contain three integers, representing an undirected edge between two cities and the length of the road between them.
Output Format
Output a single line containing several numbers in increasing order, representing the important cities. If no such city exists, output No important cities..
4 4
1 2 1
2 3 1
4 1 2
4 3 2
2
Hint
- For of the testdata, .
- For of the testdata, .
- For of the testdata, , , . Here is the length of a road.
There are no multiple edges or self-loops.
Translated by ChatGPT 5
京公网安备 11011102002149号