F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

Spanning Tree Game

Time Limit: 11000/11000 MS (Java/Others)    Memory Limit: 524288/524288 K (Java/Others)
Total Submission(s): 223    Accepted Submission(s): 98


Problem Description
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.
 

Input
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.
 

Output
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$.
 

Sample Input
1 3 3 1 2 4 6 1 3 2 7 2 3 3 5
 

Sample Output
11 9 7 5
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-05-07 05:09:50, Gzip enabled