为了账号安全,请及时绑定邮箱和手机立即绑定

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

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

慕尼黑5688855 2018-12-07 10:50:54
Problem DescriptionAs 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. InputThe 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) OutputFor each test case, output an integer which is the number of ways that selecting least key vertexes. Sample Input14 31 22 33 4 Sample Output3 Hint For the sample, there are three ways, which are selecting {1, 3}, {2, 4}, {2, 3}
查看完整描述

2 回答

?
一只名叫tom的猫

TA贡献1906条经验 获得超3个赞

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

1  ---  2

          |

4  ---  3

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

查看完整回答
反对 回复 2018-12-16
?
慕标琳琳

TA贡献1830条经验 获得超9个赞

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

查看完整回答
反对 回复 2018-12-16
  • 2 回答
  • 0 关注
  • 657 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信