首页 新闻 会员 周边 捐助

一道acm的题,看了半天,不理解题意,求解释~

0
悬赏园豆:5 [已解决问题] 解决于 2012-09-18 15:37

Problem Description
As a student in computer science, Ant is weak in Graph Theory learning. One day, he comes across a problem. Given a non-directed graph G which is donated by G = {V, E}. V is the set of vertexes and E is the set of undirected edges. You should select some vertexes as key vertexes and each edge should be connected by at least one key vertex. Ant sometimes can select the key vertexes as described above. But now he wants to select least vertexes as key vertexes. Here comes your question, given a graph and tell Ant how many ways are there to select least key vertexes.

Input
The first line of the input contains an integer T which is the number of test case, and then there are T groups of data following. For each group of data, the first line contains two integers. The first integer n is the number of vertexes and the second integer m is the number of edges. The next following m lines describe the edges. Each line contains two integers u, v which indicates there is an undirected edge connected vertex u and vertex v. (0 < n ≤ 20, 0 < m ≤ 300, u ≠ v, 1 ≤ u, v ≤ n)

Output
For each test case, output an integer which is the number of ways that selecting least key vertexes.

Sample Input
1
4 3
1 2
2 3
3 4

Sample Output
3

Hint

For the sample, there are three ways, which are selecting {1, 3}, {2, 4}, {2, 3}

斗榖於菟的主页 斗榖於菟 | 初学一级 | 园豆:60
提问于:2012-09-18 13:48
< >
分享
最佳答案
1

不知道你是不懂英文还是不懂题目。无向图什么的基础概念就不说了。题目中给出了“关键结点”(key vertex)这个概念,就是你要选择若干个关键结点,这样所有结点都跟关键结点连起来(至少有一条边)。例子中的图:

1  ---  2

          |

4  ---  3

可以看到有3条边4个点。现在需要你的程序去选择关键点。例如例子中给出的答案:选择1和3作为关键点,这样其余结点(2和4)都至少跟1个关键结点相连(2根1、3相连,4跟3相连)。 也可以选择2和4作为关键点,也可以选择2和3.一共有3种选择方法(这就是程序要的输出)。并且要求关键点是最少的,如果4个结点都是关键点,毫无疑问肯定符合其他要求,但是无法符合最少关键点的要求。

收获园豆:5
水牛刀刀 | 大侠五级 |园豆:6350 | 2012-09-18 15:21

要怎么实现呀,能说下你的想法不?

斗榖於菟 | 园豆:60 (初学一级) | 2012-09-18 16:01

@斗榖於菟: 没仔细想,不过我才从最大度数的结点开始慢慢排除应该可以的。你搞不定可以跟我说下,我有空想想。

水牛刀刀 | 园豆:6350 (大侠五级) | 2012-09-18 18:08

@水牛刀刀: 我把点和点连接的情况存在一个二维数组里,点和点之间有连线置为1,否则还是初始值0.我现在的问题是找不到一个算法确定最小点数,和最小点数情况下有几种实现的选择。没有思路...

斗榖於菟 | 园豆:60 (初学一级) | 2012-09-18 21:32
其他回答(1)
0

算出一共有多少种可能的关键点集合,使得任意关键点集合可以覆盖图中的所有边。

today4king | 园豆:3499 (老鸟四级) | 2012-09-18 15:22
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册