#P14578. 【模板】无源汇上下界可行流
【模板】无源汇上下界可行流
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 .
You need to determine whether there exists a plan such that the flow of every edge satisfies the flow restriction , and the flow is balanced at every vertex, that is, the incoming flow equals the outgoing flow at every vertex.
Construct a set of flows satisfying the above restrictions, or report that no solution exists.
Input Format
The first line contains two positive integers , representing the number of vertices and the number of edges of the graph .
The following lines each contain four non-negative 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
If a feasible plan exists, output Yes on the first line, and then lines each containing one non-negative integer , representing the actual flow of the -th edge.
If no feasible plan exists, output No.
6 7
1 2 3 5
2 3 3 4
3 4 5 6
4 1 1 5
4 5 0 3
6 3 0 1
4 6 0 1
Yes
4
4
5
4
0
1
1
6 6
4 1 0 5
4 2 0 6
4 3 0 7
4 4 3 3
5 6 1 1
6 5 2 2
No
Hint
Example 1 Explanation

The figure shows the flow plan given in the sample output.
Constraints
The graph may contain multiple edges and self-loops.
For all test data: , , , .
Translated by QwenWork