#3659. Shortest Good Path
Shortest Good Path
Shortest Good Path
题目描述
You are given a simple connected undirected graph with vertices and edges. (A graph is said to be simple if it has no multi-edges and no self-loops.)
For , the -th edge connects Vertex and Vertex .
A sequence is said to be a path of length if both of the following two conditions are satisfied:
For all , it holds that . For all , Vertex and Vertex are directly connected by an edge.
An empty sequence is regarded as a path of length . Let be a string of length consisting of and . A path is said to be a good path with respect to if the following conditions are satisfied:
For all , it holds that: if , then has even number of 's. if , then has odd number of 's.
There are possible (in other words, there are strings of length consisting of and ). Find the sum of "the length of the shortest good path with respect to " over all those . Under the Constraints of this problem, it can be proved that, for any string of length consisting of and , there is at least one good path with respect to .
输入格式
Input is given from Standard Input in the following format:
输出格式
Print the answer.
3 2
1 2
2 3
14
5 5
4 2
2 3
1 3
2 1
1 5
108
提示
The given graph is simple and connected. All values in input are integers.For , the empty sequence is the shortest good path with respect to , whose length is . For , is the shortest good path with respect to , whose length is . For , is the shortest good path with respect to , whose length is . For , is the shortest good path with respect to , whose length is . For , is the shortest good path with respect to , whose length is . For , is the shortest good path with respect to , whose length is . For , is the shortest good path with respect to , whose length is . For , is the shortest good path with respect to , whose length is .
Therefore, the sought answer is .
标签: AtCoder|abc244F
来源
AtCoder|abc244F