#P8604. [蓝桥杯 2013 国 C] 危险系数
[蓝桥杯 2013 国 C] 危险系数
Background
During the War of Resistance Against Japan, the tunnel warfare on the Jizhong Plain played an important role.
Problem Description
There are passages connecting multiple stations in the tunnel system, forming a huge network. However, there is also a hidden danger: when the enemy discovers a station, other stations may lose connectivity as a result.
We define a danger coefficient :
For two stations and , if we can find a station such that after is destroyed by the enemy, and become disconnected, then we call a key point with respect to . Accordingly, for any pair of stations and , the danger coefficient is defined as the number of key points between these two stations.
Your task is: given the network structure, compute the danger coefficient between two stations.
Input Format
The first line of the input contains integers and , representing the number of stations and the number of passages.
The next lines each contain two integers , representing a passage.
The last line contains two numbers , representing a query for the danger coefficient between the two stations.
Output Format
Output one integer. If the two queried stations are not connected, output .
7 6
1 3
2 3
3 4
3 5
4 5
5 6
1 6
2
Hint
Time limit: 1 second, 64 MB. The 4th Lanqiao Cup National Contest in 2013.
Translated by ChatGPT 5