#P1841. [JSOI2007] 重要的城市

    ID: 794 远端评测题 1000ms 125MiB 尝试: 0 已通过: 0 难度: 7 上传者: 标签>动态规划,dp图论2007各省省选江苏

[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 cc is destroyed, there exist two distinct cities aa and bb (with a,bca, b \ne c) such that the shortest distance from aa to bb increases (or becomes disconnected). In this case, city cc 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 NN and MM: NN is the number of cities, and MM is the number of roads.

The next MM 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 30%30\% of the testdata, N20N \le 20.
  • For 60%60\% of the testdata, N100N \le 100.
  • For 100%100\% of the testdata, N200N \le 200, MN×(N1)2M \le \frac{N \times (N - 1)}{2}, 0<c100000 < c \le 10000. Here cc is the length of a road.

There are no multiple edges or self-loops.

Translated by ChatGPT 5