Totally Important Edges
Time limit1sMemory limit256 MB
Given a directed flow network, count the edges whose capacity decrease by 1 lowers the maximum flow by exactly 1.
- Level
Hard8 of 10
- Topics
- Graph, Shortest path, Dynamic programming
- Solved
- No attempts yet
Problem
A directed flow graph is given. If decreasing the capacity of some edge by also decreases the graph's maximum flow by exactly , that edge is called a totally important edge.
Given the graph, count the number of totally important edges.
Input
The input consists of several test cases.
The first line contains the number of test cases ().
For each test case, the first line contains the number of vertices and the number of edges (, ). Vertex is the source and vertex is the sink.
Each of the next lines contains three integers , , and , describing an edge from vertex to vertex with capacity (). The sum of all edge capacities does not exceed .
Output
For each test case, print the number of totally important edges on its own line.