当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

6982:Road Discount

题目描述
There are $n$ cities in Byteland, labeled by $1$ to $n$. The Transport Construction Authority of Byteland is planning to construct $n-1$ bidirectional roads among these cities such that every pair of different cities are connected by these roads directly or indirectly.

The engineering company has offered $m$ possible candidate roads to construct. The $i$-th candidate road will cost $c_i$ dollars, and if it is finally constructed, there will be a road connecting the $u_i$-th city and the $v_i$-th city directly. Fortunately, each road has its discounted price, the $i$-th of which is $d_i$.

The Transport Construction Authority of Byteland can buy at most $k$ roads at their discounted prices. Please write a program to help the Transport Construction Authority find the cheapest solution for $k=0,1,2,\dots,n-1$.
输入解释
The first line contains a single integer $T$ ($1 \leq T \leq 10$), the number of test cases. For each test case:

The first line contains two integers $n$ and $m$ ($2 \leq n \leq 1\,000$, $n-1\leq m\leq 200\,000$), denoting the number of cities and the number of candidate roads.

Each of the following $m$ lines contains four integers $u_i,v_i,c_i$ and $d_i$ ($1 \leq u_i,v_i \leq n$, $u_i\neq v_i$, $1\leq d_i\leq c_i\leq 1\,000$), describing a candidate road.
输出解释
For each test case, output $n$ lines, the $i$-th ($1\leq i\leq n$) of which containing an integer, denoting the cheapest total cost to construct $n-1$ roads when $k=i-1$.

It is guaranteed that the answer always exists.
输入样例
1
5 6
1 2 1 1
2 3 2 1
2 4 3 2
2 5 4 3
1 3 5 3
4 5 6 1
输出样例
10
7
6
5
5

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-6982

最后修改于 2021-10-23T19:10:54+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
6000/6000MS(Java/Others) 524288/524288K(Java/Others)