Problem E. Maximum Weighted Matching
时间限制 4000 ms
内存限制 63.9990234375 MB
Chiaki is good at generating special graphs. Initially, she has a graph with only two vertices connected by an edge. Each time, she can choose an edge $(u,v)$, make a copy of it, insert some new vertices (maybe zero) in the edge (i.e. let the new vertices be $t_1,t_2,\dots,t_k$, Chiaki would insert edges $(u,t_1)$, $(t_1,t_2)$, $(t_{k-1}, t_k)$, $(t_k, v)$ into the graph).
Given a weighted graph generated by above operations, Chiaki would like to know the maximum weighted matching of the graph and the number different maximum weighted matchings modulo ($10^9 + 7)$).
A matching in a graph is a set of pairwise non-adjacent edges, none of which are loops; that is, no two edges share a common vertex.
A maximum weighted matching is defined as a matching where the sum of the values of the edges in the matching have a maximal value.
输入数据
输出数据
For each test case, output two integers separated by a single space. The first one is the sum of weight and the second one is the number of different maximum weighted matchings modulo ($10^9 + 7$).
样例输入
复制
2
6 7
1 2 1
2 3 1
4 5 1
5 6 1
1 4 1
2 5 1
3 6 1
4 5
1 2 1
1 3 1
1 4 1
2 3 1
3 4 1
样例输出
$ Mathjax font initiator $