连通图
题目
判断一个图是否为一个连通图
输入
n 顶点个数 ( n <= 100 )
点与点之间的边
输出
1 表示连通
0 表示不边通
样例
input
5
1 2
2 3
5 4
0 0
output
0
解题思路
建一个邻接表,从任意一个点走起,将所有点走一遍,如果能就输出 1 ,不能就输出 0 。
代码
#include<iostream>
#include<cstdio>
#include<queue>
#include<cmath>
using namespace std;
int n,x,y,tot,maxn;
int p[110],head[110];
struct c{
int x,next;
}f[501];
int