图上的连通块数量
You cannot submit for this problem because the contest is ended. You can click "Open in Problem Set" to view this problem in normal mode.
输入一个无向图,求图中连通块的个数。
输入格式
输入第一行两个整数,表示图的点的数量和边的数量,两数之间以一个空格分隔。
接下来 m 行,每行两个整数,表示一条无向边,两数之间以一个空格分隔。
输出格式
输入一行一个整数,表示图中连通块的个数。
输出时每行末尾的多余空格,不影响答案正确性
要求使用「文件输入输出」的方式解题,输入文件为 block.in
,输出文件为 block.out
样例输入
5 4
2 3
4 1
5 2
2 2
样例输出
2
20240122C_day5
- Status
- Done
- Rule
- ACM/ICPC
- Problem
- 4
- Start at
- 2024-1-26 17:30
- End at
- 2024-1-26 18:30
- Duration
- 1 hour(s)
- Host
- Partic.
- 4