#P3329. [ZJOI2011] 最小割
[ZJOI2011] 最小割
Description
Xiaobai learned a new concept—minimum cut—in a graph theory class. After class, Xiaobai wrote the following in the notebook:
For a graph, a partition of the vertices divides all vertices into two parts. If vertices and are not in the same part, then this partition is called a cut with respect to . For a weighted graph, the sum of the weights of all edges whose endpoints lie in different parts is defined as the capacity of this cut, and the minimum cut of is the cut with the minimum capacity among all cuts with respect to .
Given an undirected graph, Xiaobai has several questions of the form “how many unordered pairs of vertices have minimum-cut capacity not exceeding ”. Xiaolan would like to answer these questions but is currently busy mining wooden blocks, so as Xiaolan’s friend, the task falls on you.
Input Format
This problem contains multiple test cases.
The first line contains an integer , the number of test cases.
For each test case, the first line contains two integers , the number of vertices and edges.
The next lines each contain three integers , indicating an undirected edge with weight . Multiple edges are allowed.
Then a line with an integer follows, the number of queries. Each of the next lines contains an integer describing one query.
Output Format
For each test case, output lines, each containing one integer: the answer to the corresponding query. For a qualifying pair and the pair , count only once.
Output one empty line between two consecutive test cases.
1
5 0
1
0
10
Hint
For of the testdata, , , , , , , .
Translated by ChatGPT 5
京公网安备 11011102002149号