时间限制:C/C++/Rust/Pascal 1秒,其他语言2秒
空间限制:C/C++/Rust/Pascal 256 M,其他语言512 M
64bit IO Format: %lld
题目描述
Alice and Bob are playing a game on a simple connected graph with N nodes and M edges.
Alice colors each edge in the graph red or blue.
A path is a sequence of edges where each pair of consecutive edges have a node in common. If the first edge in the pair is of a different color than the second edge, then that is a ''color change.''
After Alice colors the graph, Bob chooses a path that begins at node 1 and ends at node N. He can choose any path on the graph, but he wants to minimize the number of color changes in the path. Alice wants to choose an edge coloring to maximize the number of color changes Bob must make. What is the maximum number of color changes she can force Bob to make, regardless of which path he chooses?
输入描述:
The first line contains two integer values N and M with
and
. The next M lines contain two integers
and
indicating an undirected edge between nodes
and
(
,
).
All edges in the graph are unique.
输出描述:
Output the maximum number of color changes Alice can force Bob to make on his route from node 1 to node N.
示例2
输入
复制
7 8
1 2
1 3
2 4
3 4
4 5
4 6
5 7
6 7