#M004. [模板题]最小费用流
[模板题]最小费用流
Problem Description
This is a template problem.
Given a graph where each edge has a capacity and a cost, using each unit of flow through an edge incurs a specific cost. Given a source node and a sink node , find the maximum flow in the graph and the minimum cost required for the maximum flow.
Input Format
The first line contains two integers and , representing nodes and edges.
The following lines each contain four integers , , , , representing an edge from node to node , with capacity and a unit flow cost of .
Output Format
Output two integers: the maximum flow and the minimum cost required for the maximum flow.
Sample Input
8 23
2 3 2147483647 1
1 3 1 1
2 4 2147483647 2
1 4 1 2
2 8 2 0
3 5 2147483647 3
1 5 1 3
3 6 2147483647 4
1 6 1 4
3 8 2 0
3 2 2147483647 0
4 6 2147483647 5
1 6 1 5
4 7 2147483647 6
1 7 1 6
4 8 2 0
4 2 2147483647 0
5 8 0 0
5 2 2147483647 0
6 8 0 0
6 2 2147483647 0
7 8 0 0
7 2 2147483647 0
Sample Output
6 24
Data Constraints and Hints
- The input data, intermediate results, and the final answer are guaranteed to fit within a 32-bit signed integer.
相关
在下列比赛中: