P21542 [Kattis] Mincostmaxflow
提高
题目描述

-----Input-----
The first line of input contains a line contains a line with four non-negative integers, $2 \le n \le 250$, $0 \le m \le 5000$, $0 \le s \le n-1$ and $0 \le t \le n-1$, separated by single spaces, where $n$ is the numbers of nodes in the graph, $m$ is the number of edges, $s$ is the source and $t$ is the sink ($s \ne t$). Nodes are numbered from $0$ to $n-1$. Then follow $m$ lines, each line consisting of four (space-separated) integers $u$, $v$, $c$ and $w$ indicating that there is an edge from $u$ to $v$ in the graph with capacity $1 \le c \le 10000$ and cost $1 \le w \le 1000$.

-----Output-----
Output a single line containing two integers; the size $F$ of a maximum flow from node $s$ to node $t$, and the cost of a mimimum cost flow of size $F$. You may assume that $F < 2^{31}$.

-----Examples-----
Sample Input 1:
4 4 0 3
0 1 4 10
1 2 2 10
0 2 4 30
2 3 4 10
Sample Output 1:
4 140

Sample Input 2:
2 1 0 1
0 1 1000 100
Sample Output 2:
1000 100000

输入格式

见题面

输出格式

见题面

样例输入
4 4 0 3 0 1 4 10 1 2 2 10 0 2 4 30 2 3 4 10
样例输出
4 140