QOJ.ac

QOJ

Time Limit: 1.5 s Memory Limit: 64 MB Total points: 100

#602. 最小费用最大流(随机数据)

统计

这是一道模板题。

给定一个图,每条边有容量和费用,使用每条边的单位流量需要支付特定的费用。给定源点 $ 1 $ 和汇点 $ n $,求图的最大流和最大流需要支付的最小费用。

Input

第一行两个整数 $ n $、$ m $,表示有 $ n $ 个点 $ m $ 条边。

从第二行开始的之后 $ m $ 行,每行四个整数 $ s_i $、$ t_i $、$ c_i $、$ w_i $ 表示一条从 $ s_i $ 到 $ t_i $ 的边,容量为 $ c_i $,单位流量需要支付的费用为 $ w_i $。

Output

一行两个整数,分别表示最大流和最大流需要支付的最小费用。

Example

Input

8 23
2 3 2147483647 1
1 3 1 1
2 4 2147483647 2
1 4 1 2
2 8 2 0
3 5 2147483647 3
1 5 1 3
3 6 2147483647 4
1 6 1 4
3 8 2 0
3 2 2147483647 0
4 6 2147483647 5
1 6 1 5
4 7 2147483647 6
1 7 1 6
4 8 2 0
4 2 2147483647 0
5 8 0 0
5 2 2147483647 0
6 8 0 0
6 2 2147483647 0
7 8 0 0
7 2 2147483647 0

Output

6 24

Notes

$1 \leq n \leq 400, 0 \leq m \leq 15000, w_i\geq 0 $,保证输入数据、中间结果以及答案在 32 位有符号整数范围内。

Source: Libre OJ 102

About Issues

We understand that our problem archive is not perfect. If you find any issues with the problem, including the statement, scoring configuration, time/memory limits, test cases, etc.

You may use this form to submit an issue regarding the problem. A problem moderator will review your issue and proceed it properly.

STOP! Before you submit an issue, please READ the following guidelines:

  1. This is not a place to publish a discussion, editorial, or requests to debug your code. Your issue will only be visible by you and problem moderators. Other users will not be able to view or reply your issues.
  2. Do not submit duplicated issues. If you have already submitted one, please wait for an moderator to review it. Submitting multiple issues will not speed up the review process and might cause your account to be banned.
  3. Issues must be filed in English or Chinese only.
  4. Be sure your issue is related to this problem. If you need to submit an issue regarding another problem, contest, category, etc., you should submit it to the corresponding page.

Active Issues 0

No issues in this category.

Closed/Resolved Issues 0

No issues in this category.