#P4123. [CQOI2016] 不同的最小割

    ID: 3212 远端评测题 3000ms 500MiB 尝试: 0 已通过: 0 难度: 8 上传者: 标签>2016重庆各省省选网络流分治最小割

[CQOI2016] 不同的最小割

Description

Students who have studied graph theory all know the concept of the minimum cut: For a graph, a partition of the nodes divides all nodes into two parts. If nodes s,ts, t are not in the same part, then the partition is called a cut with respect to s,ts, t. For a weighted graph, the capacity of a cut is defined as the sum of the weights of edges whose endpoints lie in different parts, and the s,ts, t minimum cut is the cut of minimum capacity among all cuts with respect to s,ts, t.

For contestants preparing for the NOI, finding the minimum cut between two nodes in a weighted graph is no longer difficult. Let us broaden the view: In an undirected connected graph with NN nodes, consider the minimum cut capacity for every unordered pair of nodes. In total we obtain \, N(N1)/2N(N-1)/2 \, values. How many of these values are distinct? This seems like an interesting problem.

Input Format

The first line contains two integers N,MN, M, the number of nodes and the number of edges.

Each of the next MM lines contains three integers u,v,wu, v, w, indicating there is an edge between node uu and node vv (indexed from 11) with weight ww.

Output Format

Output a single integer on the first line, the number of distinct minimum cut capacities.

4 4
1 2 3
1 3 6
2 4 5
3 4 4
3

Hint

Constraints: 1N8501 \leq N \leq 850, 1M85001 \leq M \leq 8500, 1w1000001 \leq w \leq 100000.

Translated by ChatGPT 5