Functions and Minimum Spanning Trees
Time limit3sMemory limit1024 MB
Given edges with weights at^2+b_i t+c_i (a shared), find the integral over [t1, t2] of the MST weight sum, modulo 1e9+7.
- Level
Medium7 of 10
- Topics
- Minimum spanning tree, Union-find, Math
- Solved
- No attempts yet
Problem
A simple connected graph with vertices numbered from to and edges is given.
The weight of each edge is a quadratic function that changes with time . The coefficient is the same for every edge.
Define as the sum of the weights of the minimum spanning tree at time .
Given integers and , find the value of .
A minimum spanning tree is a tree, among the subgraphs that connect all vertices of the given graph, whose total weight is minimal.
Input
The first line contains integers , , and , separated by spaces. (, , , )
Each of the next lines contains four integers , , , and , separated by spaces. (, )
This means the weight of the edge connecting vertex and vertex is .
The last line contains integers and , separated by a space. ()
Output
Print , where the value of the integral is the reduced fraction with integer and positive integer . is the multiplicative inverse of modulo .
It can be proven that the answer can be written in this form for every that is not a multiple of .
Hint
If needed, you may use .