题目:
样例:
input:
4 2
1 3
4 3
3 3
1 2
1 3
2 3
5 2
1 2
3 5
999 0
0
output:
1
0
2
998
思路:
如果道路数量为0,则直接输出n-1。如果不为0,则在输入后,求出有几个fa,然后-1(把几个fa连起来所需的线条个数)
代码:
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#define maxn 11