#M003. [模板题]最大流加强版
[模板题]最大流加强版
Problem Description
This is a template problem.
Given nodes and directed edges, each edge has a specified capacity. The task is to calculate the maximum flow from node to node .
Input Format
The first line contains four integers: .
The next lines each contain three integers: , representing a directed edge from node to node with a flow capacity of .
Output Format
Output the maximum flow from node to node .
7 14 1 7
1 2 5
1 3 6
1 4 5
2 3 2
2 5 3
3 2 2
3 4 3
3 5 3
3 6 7
4 6 5
5 6 1
6 5 1
5 7 8
6 7 7
14
10 16 1 2
1 3 2
1 4 2
5 2 2
6 2 2
3 5 1
3 6 1
4 5 1
4 6 1
1 7 2147483647
9 2 2147483647
7 8 2147483647
10 9 2147483647
8 5 2
8 6 2
3 10 2
4 10 2
8
Constraints and Hints
- , , .
- The answer is guaranteed to be less than or equal to .
- The time complexity of common maximum flow algorithms is . Try to optimize your algorithm.