Hello everyone! I am your old friend Rikka. Welcome to Xuzhou. This is the first problem, which is a problem about the minimum spanning tree (MST). I promise you all that this should be the \textbf{easiest problem}easiest problem for most people.
A minimum spanning tree, or minimum weight spanning tree, is a subset of edges from an edge-weighted undirected graph, which forms a tree with the minimum possible total edge weight that connects all the vertices together without any cycles.
In this problem, Rikka wants you to calculate the summation of total edge weights through all MSTs for a given graph, which obviously equals to the product of the total edge weight in an MST and the total number of different MSTs. Note that two spanning trees are different if the sets of their edges are different. In addition, a disconnected graph could have no MSTs, the number of whose different MSTs is zero.
To decrease the size of the input, Rikka provides an edge-weighted undirected graph via a random number generator with given random seeds, denoted by two integers k_1k
1
and k_2k
2
. Supposing the number of vertices and edges in the graph are nn and mm respectively, the following code in C++ tells you how to generate the graph and store the ii-th edge between the vertex u[i]u[i] and v[i]v[i] with weight w[i]w[i] in corresponding arrays. You can use the code directly in your submissions.
1
unsigned long long k1, k2;
2
3
unsigned long long xorShift128Plus() {