#P2740. [USACO4.2] 草地排水 Drainage Ditches
[USACO4.2] 草地排水 Drainage Ditches
Description
FJ knows the amount of water that can flow through each ditch per minute, as well as the exact layout of the drainage system (a network with the pond as the source and the creek as the sink). Note that between two places there may be more than one ditch.
Given this information, compute the maximum flow from the pond to the creek. For each ditch provided, water can flow in only one direction, and cycles may exist.
Input Format
- The first line contains two space-separated integers () and (). is the number of ditches that FJ has already dug, and is the number of junctions. Junction is the pond, and junction is the creek.
- The second line to line : each line contains three integers . and () specify the two endpoints of a ditch, and water flows from to . () is the maximum capacity of that ditch.
Output Format
Output a single integer — the maximum drainage flow.
5 4
1 2 40
1 4 20
2 4 20
2 3 30
3 4 10
50
Hint
The problem statement is translated from NOCOW.
USACO Training Section 4.2.
Constraints
For of the testdata, , .
Translated by ChatGPT 5
京公网安备 11011102002149号