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

建议使用的浏览器:

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

7166:Spanning Tree Game

题目描述
Alice and Bob are playing a game on an undirected graph with $n$ vertices and $m$ edges. The vertices are labeled by $1,2,\dots,n$. The edges are labeled by $1,2,\dots,m$. The $i$-th edge connects the $u_i$-th vertex and the $v_i$-th vertex directly, and its weight will be chosen from the given two values $a_i$ and $b_i$.

First, Alice needs to assign weights to all the $m$ edges such that there are exactly $k$ edges whose weights are taken from $a$ while the weights of other $m-k$ edges are taken from $b$. Then, Bob needs to choose exactly $n-1$ edges from the graph such that every pair of different vertices are connected by these $n-1$ edges directly or indirectly.

The final score of the game is equal to the total weights of the $n-1$ edges chosen by Bob. Alice wants to maximize the score while Bob wants to minimize it. Please write a program to predict the final score for $k=0,1,2,\dots,m$ if both of the players play optimally.
输入解释
The first line contains a single integer $T$ ($1 \leq T \leq 20$), the number of test cases. For each test case:

The first line contains two integers $n$ and $m$ ($2 \leq n \leq 9$, $n-1\leq m\leq 30$), denoting the number of vertices and the number of edges.

Each of the following $m$ lines contains four integers $u_i,v_i,a_i$ and $b_i$ ($1 \leq u_i,v_i \leq n$, $u_i\neq v_i$, $1\leq a_i,b_i\leq 1\,000\,000$), describing an edge.

It is guaranteed that the graph is connected.
输出解释
For each test case, output $m+1$ lines, the $i$-th ($1\leq i\leq m+1$) of which containing an integer, denoting the final score when $k=i-1$.
输入样例
1
3 3
1 2 4 6
1 3 2 7
2 3 3 5
输出样例
11
9
7
5

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

源链接: HDU-7166

最后修改于 2022-09-15T06:17:08+00:00 由爬虫自动更新

共提交 0

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