题目链接:1319: 球

参考:wustoj 1319 球—wust_tanyao并查集

并查集系列:WUSTOJ 1346: DARK SOULS(Java)并查集

Description

Icy is a lonely boy. He was so boring these days. So he started to play a game himself. First, he took a heap of balls with many different colors. ( One ball with only one color ) Then he repeated to pick two balls and put them back. Each time the two balls he chose is of the same color. After M times, Icy was too boring to fall asleep.

Now, a boring people wanna ask you a very easy question: how many different colors are there in the original heap at most ?

Input

The first line contains one integer T indicating the number of test cases.

For each test case, the first line contains two integer numbers N and M (0 <= N,M<= 10000) that represents the total number of balls and the number of times Icy took balls.Balls are numbered from 1 to N.Each of the following M lines contains two integer numbers A and B (1 <= A, B <= N). It means that Icy picked ball A and ball B.

一共有N个球,每个球只有一种颜色,每次取出颜色相同的两个球,然后放回去,取M次,问最多有多少种颜色?

Output

For each test case, output an integer that satisfies the problem description.

Sample Input

2
3 3
1 2
2 3
1 3
3 1
1 2

Sample Output

1
2

分析

最新文章

  1. 千呼万唤始出来!—— GG(高仿QQ)终于有移动端了!(技术原理、实现、源码)
  2. 连连看bug记录
  3. SVN使用教程总结
  4. How do you build a database?
  5. POJ 1795
  6. 完全用xml实现imageview点击换一张图片
  7. POJ 1781 In Danger Joseph环 位运算解法
  8. [js高手之路]html5 canvas动画教程 - 边界判断与反弹
  9. 微服务架构的基础框架选择:Spring Cloud还是Dubbo?
  10. 在centos7上编译安装nginx
  11. hdu-4763(kmp+拓展kmp)
  12. Confluence 6 恢复一个站点
  13. MT【21】任意基底下的距离公式
  14. 用Notepad++在文本文件里快速在每行头尾都加上指定的内容(转载)
  15. EF 数据库连接约定(Connection String Conventions in Code First)
  16. Altium中坐标的导出及利用坐标快速布局
  17. bzoj 3283 扩展BSGS + 快速阶乘
  18. JavaWeb笔记(十)非关系型数据库Redis
  19. servlet基础梳理(一)
  20. MyBatis逆向工程中domainObjectRenamingRule报错或无效

热门文章

  1. Spring boot Bean装配
  2. #C++初学记录(N皇后#回溯递归)
  3. 讲座 - Transposable elements, non-coding RNAs and epigenetic control in embryonic stem cells
  4. oracle/mysql经典电子书籍pdf下载
  5. kafka 的server.properties
  6. 产品经理 写SQL
  7. linux下apache安装ssl步骤
  8. vue plupload 的使用
  9. synchronized 同步对象概念
  10. CentOS7下搭建Redis主从复制