#M005. [模板题]无源汇有上下界可行流

    ID: 5624 传统题 1000ms 256MiB 尝试: 13 已通过: 6 难度: 8 上传者: 标签>难度分类模板图论网络流上下界网络流

[模板题]无源汇有上下界可行流

Problem Description

This is a template problem.

There are nn nodes and mm edges. Each edge ee has a lower bound lower(e)\text{lower}(e) and an upper bound upper(e)\text{upper}(e). The task is to find a feasible solution such that all nodes satisfy flow balance conditions, and all edges satisfy flow restrictions.

Input Format

The first line contains two positive integers, nn and mm.

The next mm lines each contain four integers: ss, tt, lower\text{lower}, and upper\text{upper}.

Output Format

If there is no solution, print a single line with NO.

Otherwise, print YES on the first line, followed by mm lines, each containing one integer representing the flow on each edge.

4 6
1 2 1 2
2 3 1 2
3 4 1 2
4 1 1 2
1 3 1 2
4 2 1 2
NO
4 6
1 2 1 3
2 3 1 3
3 4 1 3
4 1 1 3
1 3 1 3
4 2 1 3
YES
1
2
3
2
1
1

Constraints and Hints

$1 \leq n \leq 200, 1 \leq m \leq 10200, 1 \le s,t \le n, 0 \le \text{lower} \le \text{upper} < 3000$