#graph701. 最小生成树
最小生成树
Minimum Spanning Tree
Problem Source
BZOJ 2561
Problem Description
Given a connected undirected graph with positive edge weights, where and the vertices are numbered through .
Given three positive integers . Suppose we now add an edge of weight . What is the minimum number of edges we must delete so that this new edge could appear both in a minimum spanning tree and in a maximum spanning tree of the resulting graph?
Input Format
The first line contains two numbers .
Each of the next lines contains three positive integers , indicating an edge of weight in .
The last line contains three space-separated integers .
Output Format
Output one integer: the minimum number of edges that must be deleted.
Sample Input
3 2
3 2 1
1 2 3
1 2 2
Sample Output
1