Today is Ignatius’ birthday. He invites a lot of friends. Now it’s dinner time. Ignatius wants to know how many tables he needs at least. You have to notice that not all the friends know each other, and all the friends do not want to stay with strangers.

One important rule for this problem is that if I tell you A knows B, and B knows C, that means A, B, C know each other, so they can stay in one table.

For example: If I tell you A knows B, B knows C, and D knows E, so A, B, C can stay in one table, and D, E have to stay in the other one. So Ignatius needs 2 tables at least.

Input

The input starts with an integer T(1<=T<=25) which indicate the number of test cases. Then T test cases follow. Each test case starts with two integers N and M(1<=N,M<=1000). N indicates the number of friends, the friends are marked from 1 to N. Then M lines follow. Each line consists of two integers A and B(A!=B), that means friend A and frien

python【数据结构与算法】A - How Many Tables相关推荐

  1. Python天天美味(32) - python数据结构与算法之堆排序

    1. 选择排序 选择排序原理是先选出最小的数,与第一个数交换,然后从第二个数开始再选择最小的数与第二个数交换,-- def selection_sort(data):     for i in ran ...

  2. python数据结构与算法13_python 数据结构与算法 (13)

    python 数据结构与算法 (13) 选择排序 (Selection sort) 是? 种简单直观的排序算法. 它的? 作原理如 下.? 先在未排序序列中找到最?(?)元素, 存放到排序序列的起始位 ...

  3. python leetcode_leetcode 介绍和 python 数据结构与算法学习资料

    for (刚入门的编程)的高中 or 大学生 leetcode 介绍 leetcode 可以说是 cs 最核心的一门"课程"了,虽然不是大学开设的,但基本上每一个现代的高水平的程序 ...

  4. Python数据结构与算法(二)栈和队列

    本系列总结了python常用的数据结构和算法,以及一些编程实现. 参考书籍:<数据结构与算法 Python语言实现> [美]Michael T.Goodrich, Roberto Tama ...

  5. Python数据结构与算法(一)列表和元组

    本系列总结了python常用的数据结构和算法,以及一些编程实现. 参考书籍:<数据结构与算法 Python语言实现> [美]Michael T.Goodrich, Roberto Tama ...

  6. Python 数据结构与算法——快排

    Python 数据结构与算法--选取算法(TopK) 如果说快速选取法所代表的是剪枝式的遍历操作--在递归树中找出一条通往第 k<script type="math/tex" ...

  7. Python 数据结构与算法——从二分图到寻找最大排列(Maximum Permutation)

    假设现在有 8 位有着特殊癖好的人去买票看电影,其中有一部分人得到了自己喜欢的座位,但大多数人并不满意.现在的问题是,如果这些人各自都有自己喜欢的座位(喜欢的座位有重叠,这是进行最大排列的前提,否则无 ...

  8. Python数据结构与算法(4.1)——递归

    Python数据结构与算法(4.1)--递归 0. 学习目标 1 递归 1.1 递归的基本概念 1.2 递归的重要性 1.3 递归三原则 1.4 递归的应用 2 递归示例 2.1 列表求和 2.2 汉 ...

  9. Python数据结构与算法(3.5)——双端队列

    Python数据结构与算法(3.5)--双端队列 0. 学习目标 1. 双端队列的基本概念 1.1 双端队列的基本概念 1.2 双端队列抽象数据类型 2. 双端队列的实现 2.1 顺序双端队列的实现 ...

  10. Python数据结构与算法(3.1)——栈

    Python数据结构与算法(3.1)--栈 0. 学习目标 1. 栈的基本概念 1.1 栈的基本概念 1.2 栈抽象数据类型 1.3 栈的应用场景 2. 栈的实现 2.1 顺序栈的实现 2.2 链栈的 ...

最新文章

  1. 小计算器代码(C#)
  2. 如何发表cscd核心论文_新手如何发表论文
  3. 动态sql语句输出参数
  4. boost::mpl模块实现insert_range相关的测试程序
  5. [python爬虫] 招聘信息定时系统 (一).BeautifulSoup爬取信息并存储MySQL
  6. 微服务治理框架的选择:对比Spring Cloud和Istio
  7. MySQL回放_mysql回顾
  8. Java提高班(五)深入理解BIO、NIO、AIO
  9. vector容器详细介绍
  10. I/O设备的基本概念和分类
  11. linux 系统频率,Linux下CPU的手动频率设定
  12. Apache RewriteCond %{REQUEST_FILENAME} 不起作用问题
  13. Android AsyncTask 详解及注意事项
  14. IIC原理超详细讲解---值得一看
  15. 2021年中职“网络安全“江西省赛题—B-8:Web渗透测试
  16. python论文降重_论文怕被查重怎么办?你的降重神器来了|简明python教程|python入门|python教程...
  17. 025_GPIO的读
  18. python-docx教程
  19. 设计模式---外观(Facade)模式
  20. python企业微信回调_Python微信企业号开发之回调模式接收微信端客户端发送消息及被...

热门文章

  1. C++ 产生0-2之间的随机数
  2. GoogLeNet(从Inception v1到v4的演进)
  3. android 常见异常解决
  4. Linux上调整sshd进程的优先级
  5. 向日葵win10远程linux主机,小猪为你win10系统使用向日葵远程桌面软件远程的设置方法...
  6. java的total_Java LabelResourcePool.totalNum方法代码示例
  7. 突变检测软件 测试数据库,合作文章|变异检测软件技能大PK,谁才是Battle King?...
  8. node都会 react_学react需要node吗
  9. python处理csv文件缺失值_python 加载数据是-1为缺失值时替换为空
  10. zabbix 实践 (一)