atcoder#ABC244F. [ABC244F] Shortest Good Path
[ABC244F] Shortest Good Path
Score : points
Problem Statement
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 .
Constraints
- The given graph is simple and connected.
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
Print the answer.
3 2
1 2
2 3
14
- 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 .
5 5
4 2
2 3
1 3
2 1
1 5
108