#P14580. 【模板】有源汇上下界最小流
【模板】有源汇上下界最小流
Problem Description
You are given a directed graph with vertices and directed edges. Each edge has a lower flow bound and an upper flow bound . There are also a source and a sink .
Find the minimum flow from the source to the sink , or report that no solution exists.
Input Format
The first line contains four positive integers , representing the number of vertices and the number of edges of the graph , as well as the index of the source and the index of the sink.
The following lines each contain four positive integers , representing the starting point and the ending point of each directed edge, as well as its lower flow bound and upper flow bound.
The graph may contain multiple edges and self-loops.
Output Format
Output the minimum flow from the source to the sink . If no solution exists, output N.
6 7 1 5
1 2 3 5
2 3 3 4
3 4 5 6
1 4 1 5
4 5 0 100000
6 3 0 1
4 6 1 2
5
6 6 4 1
4 1 0 5
4 2 0 6
4 3 0 7
2 2 3 3
5 6 1 1
6 5 2 2
N
Hint
Example 1 Explanation

Here vertex is the source and vertex is the sink.
Constraints
The graph may contain multiple edges and self-loops.
For all test data: , , , , .
It is guaranteed that . For every , it is guaranteed that and .
Translated by QwenWork